在表单提交中实现jQuery确认模式?
我正在使用这样的jQuery模态确认:
$(function() { $( "#dialog-confirm" ).dialog({ resizable: false, height:190, width: 330, modal: true, buttons: { "Yes": function() { $( this ).dialog( "close" ); }, No: function() { $( this ).dialog( "close" ); } } }); }); Are you sure want to unshare?
我有一个输入按钮,forms如下:
我想在用户点击按钮时弹出对话框。 我怎样才能做到这一点?
您需要在提交按钮所在的表单中使用提交事件。
$(function() { var submit = false; $("#dialog-confirm").dialog({ resizable: false, height:190, autoOpen: false, width: 330, modal: true, buttons: { "Yes": function() { $(this).dialog("close"); submit = true; }, No: function() { $(this).dialog("close"); } } }); $('form').submit(function() { if (!submit) { $("#dialog-confirm").dialog('open'); return false; } }); });
我已经创建了没有第三方插件的模型弹出窗口。
你能不能试试给我的链接。
见演示
希望它喜欢你。