I spent the entire day trying to figure out why my custom JavaScript was not working.
Eventually I stumbled into the JQuery Update configuration and set it so that the JQuery that I use for my site was the "default (provided by Drupal)" setting and then it worked. Before it was set to 1.7 jQuery version. Looks like someone set it to 1.7 perhaps for magnific.js because that is now spitting out errors in my console "TypeError: a.off is not a function." Not sure what we use that js file for, but I find it strange that I never found anything on line about this being a potential issue when I was trying to troubleshoot my custom javascript.
Does anyone know anything about this? or am I just in left field? I know it wasn't the same issue the gentleman had in this post.
My custom code was not complex and it never worked. So I reduced it all down to just console out a simple message. But that proved to not work either. My simple console out code for my pulsing.js
is: (function ($) {
Drupal.behaviors.notWorking = {
attach: function () {
console.log("finally is working");
}
};
}(jQuery));
Ill just show the screen shots. The first one is the image where my custom code doesnt work because of jQuery update settings as I said above.
The second one is what makes my custom code actually work - but like I said magnify.js then breaks - which maybe i'll hack at it or look for a newer version or something.
Drupal.behaviors
... boilerplate code, works for any jQuery version but that which comes straight out of Drupal's box. jQuery 1.5, 1.7, none of them worked. So it sounds like the answer is do not use any other jQuery version when coding for Drupal than the one that comes straight out of the box? – Daedalus Jan 28 '16 at 22:09(function ($) { Drupal.behaviors.exampleModule = { attach: function (context, settings) { // Code to be run on page load, and console.log("hello"); } }; }(jQuery));
– Daedalus Jan 28 '16 at 22:22