在普通的html中,我这样写:
<input id="input-upload-image" type="file" multiple onchange="handleFiles(this.files)">
在Backbone中,我这样写来获得相同的功能:
events: { 'change #input-upload-image': 'handleFiles' }
handleFiles: function () {}
我的问题是如何传递this.files
到handleFiles
Backbone中的功能。
PS我尝试过,$(e.currentTarget).val();
但是即使我选择了多个文件,它也只会返回一个文件。
您可以使用change
侦听器的event参数访问输入文件
handleFiles: function (e) { console.dir(e.currentTarget.files)}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句