tomitrescak / meteor-uploads

MIT License
295 stars 41 forks source link

Reactive formData #156

Closed chongwang87 closed 9 years ago

chongwang87 commented 9 years ago

Hi Tomi, Thanks for such a wonderful package.

I had an issue regarding the reactive formData, i wish to have just one uploader and user are allow to upload their images to different places by changing the select. Is there anyway the formData capture the reactive value from the select?

here are my code Template

<select id="uploadFolder">
    <option value="avatar">Avatar</option>
    <option value="banner">Banner</option>
    <option value="Photo">Photo</option>
</select>

Template Events

'change #uploadFolder': function (e,t) {
    Template.instance().uploadFolder.set($(e.target).val());
}

Template Helpers

myFormData: function(){
    return {
        dir: 'user/' + this.user.profile.username + '/images/' + Template.instance().uploadFolder.get()
    };
}

Template onCreated

this.uploadFolder = new ReactiveVar('avatar');
chongwang87 commented 9 years ago

Great!

tomi:upload-jquery v2.2.0 now working with Session and Template.instance() on formData callback