dtracers dtracers - 1 year ago 80
jQuery Question

Have $(document).ready wait for an event before firing

For some libraries that use $(document).ready to set up handlers.

They will break if the handler is being applied to custom elements and html imports using the standard polyfills.

With the use of custom elements these events must wait for the WebcomponentsReady event to be fired

Answer Source

The solution (also mentioned here https://github.com/jquery/jquery/issues/2638)

is to use the jQuery holdReady method.

$.holdReady( true );
window.addEventListener("WebcomponentsReady", function() {
  $.holdReady( false );

This should work in all browsers

edit: fixed addEventListener

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download