pixel2 / jQuery-Easy-Confirm-Dialog-plugin

jQuery plugin that imitates the standard javascript confirm-action. But uses standard jquery dialog-module to show the message. Very simple integration, no callbacks needed. When added all other events will be put on hold and only executed on user confirmation.
http://projectshadowlight.org/jquery-easy-confirm-dialog/
25 stars 20 forks source link

order of buttons #4

Closed brgrz closed 11 years ago

brgrz commented 12 years ago

Since it's impossible to change the order of the buttons on the fly, I propose you change the button initialisation so that it keeps the order as set in the "button: ..." option (currently you change those two up, putting the 2nd one first and the 1st one second) and to favor that the "Cancel" gets selected by default (preventing accidental confirms).

brgrz commented 12 years ago

Like this

        // Modified buttons initialisation here
  var buttons = {};

  buttons[locale.button[0]] = function () {
    $(dialog).dialog("close");
  };

  buttons[locale.button[1]] = function () {
    // Unbind overriding handler and let default actions pass through
    $target.unbind(type, handler);

    // Close dialog
    $(dialog).dialog("close");

    // Check if there is any events on the target
    if (jQuery.data(target, 'events')) {
      // Trigger click event.
      $target.click();
    }
    else {
      // No event trigger new url
      urlClick();
    }

    init();
  };
pixel2 commented 11 years ago

The order of the buttons are now kept intact, however the OK button is still focused by default (since this seam to be the default behavior of chrome/firefox).