I have been trying unsuccessfully to add Drupal behaviors to an existing and workding JS script file that is wrapped in :
jQuery(document).ready(function($){
// some JS here
Drupal.behaviors.ios = {
attach: function (context, settings) {
// Code to be run on page load, and
// on ajax load added here
}
};
});
I cannot get my behaviours to work.
However I have changed the wrapper to :
(function($){
// some JS here
Drupal.behaviors.ios = {
attach: function (context, settings) {
// Code to be run on page load, and
// on ajax load added here
}
};
})(jQuery);
and now the behaviours work.
What is the difference between the wrappers and can I expect the existing Javascript to continue functioning if I make this change ?