toranb / ember-file-upload

basic ember.js django app showing file upload in action
42 stars 6 forks source link

Can't set data in controller #2

Open Nininea-zz opened 10 years ago

Nininea-zz commented 10 years ago

i used this uploader view export default Ember.TextField.extend({ type:'file', attributeBinding:['name'], change:function(evt){ var input = evt.target; if (input.files && input.files[0]) { var read=new window.FileReader(); var self=this; read.onload=function(e) { var fileToUpload=read.result; self.get('controller').set(self.name, fileToUpload); window.console.log("data setted"); }; read.readAsDataURL(input.files[0]); } } }); inside my template use view like this

{{view "upload-file" name="bankdocument" contentBinding="content"}}

when try submit, value is "bankdocument" empty I dont use another view, submit action is inside controller : export default Ember.ObjectController.extend({

bankdocument:null,  
actions:{    
submit:function(){
    window.console.log('submited');
    var doc=this.get('bankdocument');
    window.alert(doc);            
    }
}

});

how can I fix this problem?

toranb commented 10 years ago

I'm into react these days so ... a few questions to help debug the issue.

What version of ember are you using with this. If you throw a debugger inline can you see if self.get('target') is actually the controller (not sure how the latest ember works these days but I felt it was worth asking a few questions first)