I’m using uploadify fileupload control in my MVC3 application.
I’m trying to put the fileupload browse button in jQuery dialog box.
When i used the jQuery dialog box to render the content of fileupload, it worked fine in firefox but it doesnot work in Chrome.
I could see the Browse button in jQuery dialog box, but unable to click.
I’ve noticed that if modal:true is set to Dialog box, it is not working. If i comment out the modal it works fine.
However i could see this post, but i couldnt help me. Still having the same issue
Here is my HTML:
<body>
<div id="fileupload" style="display:none">
<div style="clear: none;">
File to Upload:
<input type="file" name="file_upload" id="file_upload" style="padding-left: 50px;"/><hr />
</div>
<p style="text-align: right;">
<input type="submit" id="selectimage" value="Ok" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"/>
<input type="submit" id="cancelimage" value="Cancel" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" onclick="cancelupload();" />
</p>
</div>
<input type="button" id="btnImg" />
</body>
Here is my javascript:
$(function(){
$("#btnImg").click(function () {
$("#fileupload").dialog({
width: '511',
height: '200',
modal:true,
//show: "blind",
position: [300, 500]
});
});
});
If i use
$('#fileupload').dialog({ modal: true, autoOpen: false });
prior to the above code, i’m unable to get the popup when btnImg is clicked
Any help could be appreciated
Additional from comments:
Uploadify has a z-index of 1 applied automatically that needs changing.
Add this to your CSS to fix the problem:
Original answer:
Just tested this out in Chrome and the problem as far as my tests have gone is the HTML structure you’re using.
jQuery-UI Dialog will take an element from anywhere in the DOM and display it as a dialog, it doesn’t need to be nested within the input elements button.
Notice that the modal window html is outside the container and hidden. This guarantees you that the stacking order of parent elements has no effect on the dialog html.
As an extra, you don’t even need DOM elements to create dialogs. You can build the dialog in jQuery or javascript and then call dialog on it.