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

Using options var => Clicking 'Cancel' closes after 2nd click (not first) #18

Closed smartey closed 9 years ago

smartey commented 9 years ago

VERSION 1.1.X

When using a an 'options' var like the one below, clicking cancel in the dialog window doesn't respond the first time but the second click it does closing the dialog.

Code used in php: var options = { message: "The famouse question?", title: 'Header title', size: 'sm', subtitle: 'smaller text header', label: "True", function(result) { result ? DoSomething : ' ' } };

Actual call (javascript): eModal.confirm(options);

Regards, Eric

saribe commented 9 years ago

Hi Eric!

I can see some issues in you code!

1# if version <= 1.1.x Your options is miss constructed!

var options = {
  message: 'The famous question?',
  title: 'Header title',
  size: eModal.size.sm,
  subtitle: 'smaller text header',
  label: "True",
  callback: function(result) { if(result){ DoSomething();} }
};

eModal.confirm(options);

2# if version >= 1.2.x

var options = {
  message: 'The famous question?',
  title: 'Header title',
  size: eModal.size.sm,
  subtitle: 'smaller text header',
  label: "True"
};

eModal
   .confirm(options)
   .then(DoSomething/*, optionalDoSomethingElseOnNegative*/ );
smartey commented 9 years ago

My apologies, I wasn't aware of my code 'miss' and thank you for your reply!

Regards, Eric