-1

I need to focus node when onClose event. but always focused clicked button.

        $.alert({
            title: 'title',
            content: 'message,
            onClose : function () {
                $('input[name="title"]').focus();
            }
        });
Shooky
  • 9
  • 1

1 Answers1

0

By default jQuery-confirm keeps track of the last focused element when it is opened, and when it is closed, it returns the last focused element to focus.

So work around for that:

Example:

$.alert({
  title: 'title',
  content: 'message',
  onClose: function() {
    this._lastFocused = $('input[name="title"]');
    // this will notify jquery-confirm to focus the  element when it close.
  }
});
4b0
  • 21,981
  • 30
  • 95
  • 142