admin管理员组文章数量:1435859
Is there a way i can use a jQuery UI based modal dialog for confirmation instead of the normal JS confirm()? I would like to be able to do something like:
if (jquery_ui_confirm('Are you sure?')) {
// do something
}
Thanks in advance.
Is there a way i can use a jQuery UI based modal dialog for confirmation instead of the normal JS confirm()? I would like to be able to do something like:
if (jquery_ui_confirm('Are you sure?')) {
// do something
}
Thanks in advance.
Share Improve this question asked May 24, 2013 at 10:25 Gonçalo MarrafaGonçalo Marrafa 2,1134 gold badges29 silver badges35 bronze badges 3- It's a bit more plicated because you need to provide the HTML for the dialog box and handle the result as callbacks, but yeah there's no reason this can't work. Have you tried it? – Rup Commented May 24, 2013 at 10:26
- 2 ... Its part of the basic docs; jqueryui./dialog/#modal-confirmation – Alex K. Commented May 24, 2013 at 10:27
- you can also use Jquery Alert plugin as well. – Muhammad Sannan Khalid Commented May 24, 2013 at 10:34
3 Answers
Reset to default 4var jqConfirm = function(msg, success) {
var dialogObj = $("<div style='display:none'>"+msg+"</div>");
$("body").append(dialogObj);
$(dialogObj).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"OK": function() {
success();
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
};
Call this function using
jqConfirm("This will delete all records", function(){ /*do something here */});
yes you can.. you can provide requried html to dialog
<script>
$(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"OK": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>
HTML Code
<div id="dialog-confirm" title="Confirmation Dialog">
<p>
<span class="ui-icon ui-icon-alert"
style="float: left; margin: 0 7px 20px 0;"></span>Would you like to delete this item?
</p>
</div>
you can also use Jquery Alert plugin as well. Here is a link: http://labs.abeautifulsite/archived/jquery-alerts/demo/
本文标签: javascriptUsing jQuery UI modal dialog as confirmStack Overflow
版权声明:本文标题:javascript - Using jQuery UI modal dialog as confirm - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745675321a2669817.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论