I'm writing my first jquery plugin and wondered what the correct/best practice way of referencing another function from within a plugin was? Is there a better way to define bar in my plugin script. Should it be within function($) ? I'd also like it to be available to other plugins within the script.
function bar() {
return 'is this best paractice?';
}
(function($) {
$.fn.foo = function() {
alert(bar());
};
}(jQuery));
Why doesn't something like this work:
(function($) {
$.fn.bar = function() {
return 'is this best paractice?';
};
}(jQuery));
(function($) {
$.fn.foo = function() {
alert(bar());
};
}(jQuery));
Thanks