how to use jquery UI dialog as javascript confirm?

后端 未结 3 1474
不知归路
不知归路 2021-01-07 03:01

I read lots of questions about this, but every solution uses the same workaround, submiting the form inside the jquery dialog, something like this:

 $(\"#dia         


        
3条回答
  •  我在风中等你
    2021-01-07 03:32

    I wrote the following code to use JQuery's UI Dialog as a modal confirmation. By submitting the form via the event target there is not a recursive call to the submit event handler.

    $(function () {
        $('form[action*="/Delete"]').submit(function (e) {
            e.preventDefault();
    
            $("
    Are you sure you want to delete this?
    ").dialog({ resizable: false, height: 140, modal: true, buttons: { Ok: function () { e.target.submit(); }, Cancel: function () { $(this).dialog("close"); } } }); }); });

提交回复
热议问题