I have a custom views plugin. When the view is displayed, the javascript below gets loaded. Note the custom method, do_stuff
, which gets called from within Drupal.behaviors
.
(function ($) {
$.fn.do_stuff(indx){
alert (indx);
}
Drupal.behaviors.mymodule = {
attach: function (context, settings) {
if (settings.hasOwnProperty('mymodule')) {
$('.my-item').each(function(indx, item) {
// do stuff to each item
$(this).do_stuff(indx);
});
}
}
}
}(jQuery));
I would now like to create a second plugin, which loads a second javascript file. This second javascript file needs access to the custom method, do_stuff
. Is there a way I could access the do_stuff
code defined in the first javascript file, from within the second javascript file? For example, is there a way to move the custom method inside Drupal.behaviors, so that it could then be accessed from within any other javascript file?