简体   繁体   中英

jQuery and Drupal behavior issue on document.ready

I have an odd problem in my jQuery code that loads in Drupal 7 . I used the following instruction :

(function ($) {

  Drupal.behaviors.exampleModule = {
    attach: myPopUpFunction.....

})(jQuery);

On my mac browsers this codes loads after the document is loaded however on PC the popUp loads first and then the whole page loads.

Any idea?

Thank you,

not sure if your issue is browser specific, but my suggestion is that you could bind the myPopUpFunction with the window's load event, in that way only after the window's elements are all loaded the popup method would be triggered invoking the popup load

$(window).bind('load', function() {
// popup load goes here
});

this should serve the cause, but the popup would load after 'all' the elements including images which might not be desired.

Note: jQuery 1.7 onward suggests method . on() instead of bind.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM