admin管理员组文章数量:1203384
On my web page I have a jQuery UI Dialog. When I click the button (create new user) it opens a new window. My question is how can I open that window with an AJAX request?
It would be nice to open the dialog-form from another page. For example: dialog.html
<div id="dialog-form" title="Create new user">
<p class="validateTips">All form fields are required.</p>
<form>
<fieldset>
<label for="name">Name</label>
<input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
<label for="email">Email</label>
<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
<label for="password">Password</label>
<input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
</div>
You can see full code in this fiddle:
On my web page I have a jQuery UI Dialog. When I click the button (create new user) it opens a new window. My question is how can I open that window with an AJAX request?
It would be nice to open the dialog-form from another page. For example: dialog.html
<div id="dialog-form" title="Create new user">
<p class="validateTips">All form fields are required.</p>
<form>
<fieldset>
<label for="name">Name</label>
<input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
<label for="email">Email</label>
<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
<label for="password">Password</label>
<input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
</div>
You can see full code in this fiddle:
Share Improve this question edited Feb 26, 2014 at 19:26 CommandZ 3,6111 gold badge24 silver badges28 bronze badges asked Oct 9, 2013 at 9:06 user2767715user27677153 Answers
Reset to default 11You can define your dialog like this :
function showUrlInDialog(url){
$.ajax({
url: 'dialog.html',
success: function(data) {
$("#dialog-form").load(data).dialog({modal:true}).dialog('open');
}
});
}
And define the current markup that is inside dialog-form div, into a new page called dialog.html. Call the above written function on the button click event. I hope this is what you needed.
I think this is a simpler version of the answer:
$("#the-button").click(function(){
$("#dialog").dialog({modal: true}).dialog('open')).load("dialog.html")
})
For me .load is not working. So I used,
function showUrlInDialog(url){
$.ajax({
url: 'dialog.html',
success: function(data) {
$("#dialog-form").html(data).dialog({modal:true}).dialog('open');
}
});
}
本文标签: javascripthow to open jQuery UI dialog with AJAX requestStack Overflow
版权声明:本文标题:javascript - how to open jQuery UI dialog with AJAX request? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738668062a2105823.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论