I have the following code:
$(document).ready(function () {
function loginLinkClick(e) {
e.preventDefault();
$('#loginLink').unbind('click', loginLinkClick);
dialog(this);
}
function registerLinkClick(e) {
e.preventDefault();
$('#registerLink').unbind('click', registerLinkClick);
dialog(this);
}
$('#loginLink')
.bind('click', loginLinkClick);
$('#registerLink')
.bind('click', registerLinkClick);
$('#logoutLink')
.click(function (e) {
window.location = $(this).attr('data-href')
});
});
I want to have my loginLinkClick and registerLinkClick functions available to other javascript files. Is there a way that I can do this? I’m using jQuery so should I put them into the jQuery namespace or something like that?
One more question. From a performance point of view or for maintainability should I have functions like these outside of the $(document)
To make the functions available outside of that scope, instead of
try adding them to the window object with