-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathfileField.js
30 lines (29 loc) · 1016 Bytes
/
fileField.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Template.simpleFormFileField.helpers({
originalFileName: function() {
if (Session.get(this.field + 'OriginalFileName')) {
return Session.get(this.field + 'OriginalFileName')
} else {
return this.object[this.field + "OriginalFileName"]
}
},
file: function() {
if (Session.get(this.field + 'Url')) {
return Session.get(this.field + 'Url')
} else {
return this.object[this.field + 'Url']
}
}
})
Template.simpleFormFileField.events({
'click .remove': function(event) {
event.preventDefault()
Meteor.call("uploaderDelete", $(event.target).parent().attr('href'), function() {
Session.set(this.field+ 'OriginalFileName', undefined)
Session.set(this.field + 'Url', undefined)
$('input[name="'+ this.field +'Url"').val(undefined)
$('input[name="'+ this.field +'OriginalFileName"').val(undefined)
this.object[this.field + 'Url'] = undefined
this.object[this.field + 'OriginalFileName'] = undefined
}.bind(this))
}
})