问题
I use Valums qq.FileUploader(ex-AjaxUpload) plugin for uploading in my Asp.net mvc 3 application...
I have some button in my page add-newimage
, and by clicking in it I get modal window, and I load data into that window by loading Partial View.
And in that partial view I have button upload-image
, in which I want to initilaize my qq.FileUploader, but it doesn't work anywhere...
Here is code
$("#add-newimage").click(function () {
$("#add-image").load('/Design/AddImage/', function () {
$("#add-image").dialog('open');
var uploader= new qq.FileUploader({
element: document.getElementById("upload-image"),
action: '/Design/UploadImage',
allowedExtensions: ['jpg'],
onComplete: function (id, fileName, responseJSON) {
$("#hidden-path input").html("/Img/Temp/@User.Identity.Name/" + file);
alert($("#hidden-path input").html());
}
});
});
});
How can I make it work?
回答1:
I would try to put the uploader code in the open event of your dialog.
$("#add-image").dialog({
open : function(event, ui) {
var uploader= new qq.FileUploader({
element: document.getElementById("upload-image"),
action: '/Design/UploadImage',
allowedExtensions: ['jpg'],
onComplete: function (id, fileName, responseJSON) {
$("#hidden-path input").html("/Img/Temp/@User.Identity.Name/" + file);
alert($("#hidden-path input").html());
}
}
});
..
$("#add-newimage").click(function () {
$("#add-image").load('/Design/AddImage/', function () {
$("#add-image").dialog('open');
});
});
来源:https://stackoverflow.com/questions/7592787/valums-qq-fileuploader-doesnt-work-when-its-initialized-after-loading-button-b