diff --git a/index.html b/index.html index 22109b3..b715ceb 100644 --- a/index.html +++ b/index.html @@ -1278,6 +1278,8 @@

text: 'Hey there!', btnClass: 'btn-blue', keys: ['enter', 'a'], + hide: false, // initially not hidden + disabled: false, // initially not disabled action: function(){ // button action. } @@ -1455,7 +1457,7 @@

Button keys

'Press <span style="font-size: 20px;">Y</span> to proceed.', buttons: { yes: { - btnClass: 'hide', // hide is a bootstrap class to hide elements + hide: true, // hide the button using CSS keys: ['y'], action: function () { $.alert('Critical action <strong>was performed</strong>.'); @@ -1506,7 +1508,7 @@

Button keys

'Press Y to proceed.', buttons: { yes: { - btnClass: 'hide', // hide is a bootstrap class to hide elements + hide: true, keys: ['y'], action: function () { $.alert('Critical action was performed.'); @@ -1549,8 +1551,11 @@

Button functions

} }, reset: function () { + this.buttons.buttonB.show(); this.buttons.buttonA.enable(); - this.buttons.buttonB.setText('button b'); + this.buttons.buttonB.setText('button B!!'); + // this.buttons.buttonA.hide(); + // this.buttons.buttonA.show(); return false; } } @@ -1670,8 +1675,11 @@

Button functions

} }, reset: function () { + this.buttons.buttonB.show(); this.buttons.buttonA.enable(); - this.buttons.buttonB.setText('button a'); + this.buttons.buttonB.setText('button B!!'); + // this.buttons.buttonA.hide(); + // this.buttons.buttonA.show(); return false; } } diff --git a/js/jquery-confirm.js b/js/jquery-confirm.js index f7aeb5f..5ea9c9f 100644 --- a/js/jquery-confirm.js +++ b/js/jquery-confirm.js @@ -627,14 +627,20 @@ var jconfirm, Jconfirm; that.buttons[key].keys[i] = a.toLowerCase(); }); - var button_element = $('').click(function (e) { - e.preventDefault(); - var res = that.buttons[key].action.apply(that); - that.onAction(key); - that._stopCountDown(); - if (typeof res === 'undefined' || res) - that.close(); - }); + var button_element = $('') + .html(that.buttons[key].text) + .addClass(that.buttons[key].btnClass) + .prop('disabled', !!button.disabled) + .css('display', (!!button.hide) ? 'none' : '') + .click(function (e) { + e.preventDefault(); + var res = that.buttons[key].action.apply(that); + that.onAction(key); + that._stopCountDown(); + if (typeof res === 'undefined' || res) + that.close(); + }); + that.buttons[key].el = button_element; that.buttons[key].setText = function (text) { button_element.html(text);