Hi all,
I have several functions which use jquery that are called across different pages. I'm wondering if it's possible to define these functions in a single file, and then call them in different files which are included after the initial file.
Here's an example:
## default.js
$(function() {
// jquery specific functions here...
function showLoader(update_area) {
update_area.ajaxStart(function() {
update_area.show();
$(this).html('<img id="loading" src="images/loading.gif" alt="loading" />');
});
}
});
## other_file.js (included after default.js)
update_area = $('#someDiv');
showLoader(update_area);
When I do this, firebug gives me 'showLoader is not defined. I'm assuming that's because of the scope of the $(function() { }); which contains the jquery-specific functions. If that's the case, though, doesn't that mean I'll need to have the same code defining the functions in each js file I call them in?
How can I separate these things properly?
Thanks!