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 g开发者_JS百科et 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?
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');
});
});
精彩评论