saribe / eModal

Easy Modal for bootstrap, is a simple way to create modal dialogs using javascript.
http://saribe.github.io/eModal
271 stars 97 forks source link

Swap classes of buttons in confirm #43

Closed beruic closed 8 years ago

beruic commented 8 years ago

I am making a confirm modal for some delete actions, and I'd like the "Yes" button to be danger, instead of the "No" button. Is this possible, or do I need to make an alert and define buttons instead?

saribe commented 8 years ago

Right now the easy way is to change the DOM

after execute const customPromise = eModa[ACTION](args);

You can get the DOM element with

customPromise.element;

and you can manual swap them with jQuery

const no = customPromise.element.find('.btn-danger').removeClass('btn-danger');
const yes = customPromise.element.find('.btn-primary').removeClass('btn-primary');
no.addClass('btn-primary');
yes.addClass('btn-danger');
saribe commented 8 years ago

now you ca do: eModal.confirm({ message: 'whats up', style: ['warning', 'muted']})