Hi All,
I am sharing my recent experience with C-Tools modal form, I was adding custom js file in ctools modal form in Drupal 7.x using jQuery version 1.8
ctools_ad_js();
and add my code under
document.ready(),
but my code didn't work and I am sure the code has no issue as the same code was working absolutely fine when I was adding the js without using ctools modal form.
After making a lot fight on google I got a solution that with jQuery version 1.8 or greater, ctools modal form will not work with document.ready, instead of using this, you must have to use Drupal.behaviors, if you want to add custom jQuery code.
So it's a suggestion if anyone stuck with such an issue, go head with Drupal.behaviors in the following manner and it really works:
Sample Code:
(function ($, Drupal, window, document, undefined) {
Drupal.behaviors.my_custom_behavior = {
attach: function(context, settings) {
/// your code goes here
}
};
})(jQuery, Drupal, this, this.document);
If you want go in deep, you can refer this link to understand more about drupal behaviours:
https://drupal.org/node/756722#behaviors
Thanks
0 Comment(s)