vodkabears / Remodal

No longer actively maintained.
http://vodkabears.github.io/remodal/
MIT License
2.75k stars 769 forks source link

Why the remodal instance removes the jquery methods? #209

Closed lemagnetic closed 8 years ago

lemagnetic commented 8 years ago

I would like to do this:

$('.remodal').remodal().on('opened', callback);

or this

var remodalInst = $('.remodal').remodal();
remodalInst.on('opened', callback);

:/

usb248 commented 8 years ago

Firstly, callback are on $(document) (the descendants of the selected elements .remodal), not on the remodal instance... (Read the doc ...).

$(document).on('opened', '.remodal', function () {
  console.log('Modal is opened');
});

The plugin return remodal instance, so you can call public method.

In the jquery documentation : The .on() method attaches event handlers to the currently selected set of elements in the jQuery object

If you want to keep your code :

var remodalInst = $('.remodal').remodal();
$(document).on('opened', '.remodal', function () {
  callback();
});