user3378165 user3378165 - 1 month ago 7
jQuery Question

jQuery UI - Close dialog on inpute change outside

How do I close any open jquery-ui dialog if any input change is being made in the page outside the open dialog?

I wrote this code:

$("input").keyup(function () {
$(".ui-dialog-content").dialog("close");
});


That works fine, but that closes the dialog even if a input change is being made withing the dialog, I only need to close the dialog if an input change is being made in the page, outside the dialog.

Please advise.

Answer

That close any open jquery dialog on any input change on the page.

  $('.ui-widget-overlay').live("click", function () {
    $("#dialog").dialog("close");
  });