简体   繁体   中英

jQuery confirm dialog not closing

I have a jQuery confirm dialog which is not closing on the dialog("close") .

$.confirm({
  title: 'Change From Date',
  content: url,
  buttons: {
    confirm: function() {
      $(this).dialog("close");
    },
    cancel: function() {
      $(this).dialog("close");
    }
  }
});

Change the selector you are using for the .dialog('close') method - instead of

$(this).dialog('close');

change it to:

$('.yourDialogClassOrID').dialog('close');

That is, whatever selector you use to initialize the dialog, use that selector for the .dialog('close') instruction:

EG

$( "#mydialog" ).dialog(); //initialize dialog
use:
$( "#mydialog" ).dialog('close'); //close dialog

The easiest way that I have found is the following:

jconfirm.instances[0].close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM