To organize my code, I happened to write as namespace for my main javascript file. Then I want to call some of the functions of that file to my custom javascript file, let say script.js. The problem is that I couldn't access the methods of the namespace. Here is my example code:
main.js
$( function() {
"use strict"
var Accordian = {
slide : function() {
$('h3').click( function() {
$(this).next('div').slideToggle('1000');
$(this).toggleClass('toggled');
});
},
slideEaseOutBounce: function() {
$('h3').click( function() {
$(this).next().animate(
{'height' : 'toggle'}, 1000, 'easeOutBounce'
);
$(this).toggleClass('toggled');
});
},
slideEaseInOutExpo: function() {
$('h3').click( function() {
$(this).next().animate(
{'height' : 'toggle'}, 1000, 'easeInOutExpo'
);
$(this).toggleClass('toggled');
});
}
});
And I have tried as in below script.js
$(document).ready( function() {
Accordian.slide();
});
UPDATED:
Here's the link: http://jsnamespace.comyr.com/using-accordian.html
And the error message occurs "ReferenceError: Accordian is not defined"
Any help would be very much appreciated.