Hello,
This is about version 8.x
From what I understand, Drupal.behaviors is to be used instead of $(document).ready, so the presence of $(document).ready inside Drupal.behaviors in script.js is useless. Actually, I tried putting some code inside $(document).ready located inside Drupal.behaviors and it executes twice. So not only this is not necessary, but it actually does not work properly.
I don't know about $(window).load, $(window).resize and $(window).scroll, but something tels me they should not be put inside Drupal.behaviors either.
The Zen theme is pretty well documented, yet it does not add anything like those inside Drupal.behaviors
What do you guys think?
Comment | File | Size | Author |
---|---|---|---|
#6 | basic_scripts-js-2778723.patch | 1.8 KB | leahtard |
Comments
Comment #2
joelpittetAgreed and we shold probably change the documentation link to the D8 one
https://www.drupal.org/node/2269515
Those jQuery methods will still work, but DOM ready is a bit redundant.
It's called twice because there must be some ajax on the page I'm guessing, it should only call once unless there is a bug in core when there is no ajax calls.
Comment #3
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedAlso, looks like the anonymous closure syntax is not correct though it still works...
It should be
(function($) {})(jQuery);
when it currently is
(function($) {}(jQuery));
Comment #4
joelpittetYeah we can change that closure for both 7 and 8
Comment #5
joelpittet@Nicolas Bouteille would you mind making a patch for these changes?
Comment #6
leahtard CreditAttribution: leahtard at The Jibe commentedHey all,
Here is a patch.
Cheers, Leah
Comment #8
leahtard CreditAttribution: leahtard at The Jibe commented