- [Drupal 7.43]
- [Production Linux Environment]
- [Omega4 Sub-Theme]
- [jQuery-Update-Module-7.x-3.0-alpha3]
(Some Questions) I am using jQuery on my website to accomplish several fixes:
- Make iPhones respond to Hover Events.
- Add a Div-wrapper to enclose a group of Navigation-Links.
- Create an Accordion Navigation Drop-Down.
- Stop Google-Maps-Windows from scrolling in Mobile environments, eclipsing the regular page scroll.
I have integrated jQuery using the MyTheme-Info strategy. That is, that I have added the script-tag of the fixes individually to the MyTheme.info file. Then I have uploaded the corresponding Fix-01.js files to the server. Basically, this seems to be working, but I have some questions and these concern the BONUS weirdness that Drupal adds to the already amply weird jQuery itself.
I know that I have to wrap the "Fix-0x.js" files in the code:
Code Wrapper #1
(function ($) {
//Some amazing code here
}(jQuery));
As I understand it, this allows jQuery to use the '$' symbol without clashing with other libraries that also use this same symbol.
I know that jQuery also MUST wait for the DOM to load before the script can have any access to the elements of the DOM. Often this is done with the code:
Code Wrapper #2
$(document).ready(function() {
//Some amazing code here
});
Or sometimes it is written:
Code Wrapper #3
$(function() {
//Some amazing code here
});
The question is, does the first jQuery wrapper (Code-Wrapper #1) include the Document-Ready function or not (Code-Wrapper #2). Do I have to wrap the jQuery in BOTH wrappers? I know that Code-Wrapper #2 and Code-Wrapper #3 are equivalent.