表示腳本可以從骨幹視圖訪問。問題是插件嘗試訪問窗口對象的方式。我使用了不同的腳本,它運行良好。這就是我用什麼:
uploader.js
function my_uploader(evt) {
var files = evt.target.files; // FileList object
// Loop through the FileList and render image files as thumbnails.
for (var i = 0, f; f = files[i]; i++) {
// Only process image files.
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (function(theFile) {
return function(e) {
// Render thumbnail.
var span = document.createElement('span');
span.innerHTML = ['<img class="thumb" src="', e.target.result,
'" title="', escape(theFile.name), '"/>'].join('');
document.getElementById('list').insertBefore(span, null);
};
})(f);
// Read in the image file as a data URL.
reader.readAsDataURL(f);
}
}
骨幹視圖腳本
events: {
"change #signageUploadInput": "loadImage",
},
loadImage: function(evt) {
my_uploader(evt); //script is inside fileuploader.js
}
刪除我的答案。無法閱讀您正在使用插件。我可以問你使用的插件嗎? – jmk2142
我使用這個插件https://github.com/blueimp/JavaScript-Load-Image – alexndm