rmariuzzo / checkboxes.js

☑️ A jQuery plugin that gives you nice powers over your checkboxes.
http://rmariuzzo.github.io/checkboxes.js
MIT License
134 stars 25 forks source link

Fix: #23 - JQMIGRATE: 'ready' event is deprecated #27

Closed jengjeng closed 7 years ago

jengjeng commented 7 years ago

23

Fix: - JQMIGRATE: 'ready' event is deprecated.

rmariuzzo commented 7 years ago

Thanks for pointing this @jengjeng! I will think about it before merging as I decided to use the “data-api” with the idea that it could be disabled. I have to think a little about it.

rmariuzzo commented 7 years ago

@jengjeng can you change the branch to point to develop instead of master?

jengjeng commented 7 years ago

Hi, How about if we change the ready event to the custom event then we can detach ready event simply by using .off eg.

$(document).on('checkboxes.data-api.ready', dataApiDomReadyHandler);
$(document).ready(function () {
   $(document).trigger('checkboxes.data-api.ready');
});

then

$(document).off('checkboxes.data-api.ready');
rmariuzzo commented 7 years ago

Actually, it doesn't matter for the ready event to be namespaced. It would be a race condition trying to turning off an event that run once on DOM ready...

That said, let just use the bit of code you just provided. But instead of using: $(document).ready(fn) use the recommended one: $(fn).

As of jQuery 3.0, only the first syntax is recommended [$( handler )]

In the end, we just want something as:

$(dataApiDomReadyHandler);