Vex confirm dialog, cancel-action by default

I am trying to use https://github.com/HubSpot/vex modal script to confirm a dialog. At this point, if a confirmation dialog appears, the default is ok-button. Does anyone know how I can change this? I would like the cancel button to be the default, so that someone clicks only enter, nothing happens.

thanks for your reply.

Best regards thomas

+3
source share
2 answers

set the button text in your array

vex.dialog.open({          
    message: 'Are you absolutely sure you want to destroy the alien planet?', 
    overlayClosesOnClick: false, // set false to click out
    callback: function (value) {
        console.log(value);
    },
    buttons: [
        $.extend({}, vex.dialog.buttons.YES, { text: 'Your Button For Yesy' }),
        $.extend({}, vex.dialog.buttons.NO, { text: 'Your Button For No' })
    ]
 });
+6
source

To change this as the default behavior, change the order of the buttons and the class name in the JavaScript vex file. (Vex.combined.js)

"" .

dialog.buttons = { 
        NO: {
          text: 'Cancel',
          type: 'button',
          className: 'vex-dialog-button-primary',
          click: function noClick () {
            this.value = false
            this.close()
          }
        },
        YES: {
          text: 'OK',
          type: 'submit',
          className: 'vex-dialog-button-secondary',
          click: function yesClick () {
            this.value = true
          }
        }
}

dialog.defaultOptions = {
    ..
    buttons: [
      dialog.buttons.NO,
      dialog.buttons.YES
    ],
    ..
  }
0

All Articles