I have been working on a new project for sometime and recently started using require.js in the project.
It all seemed to work fine until I tried making a call from application.js to dashboard.js when the tab #dailyTab or #weeklyTab was clicked or access varialbe var a in dashboard,js. My code is below
main.js
requirejs.config({
baseUrl : '../static/js/',
paths : {
'jquery' : 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min',
'jquery-ui' : 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min',
'bootstrap' : ['//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min', 'bootstrap.min'],
},
shim : {
'bootstrap' : ['jquery'],
'bootswatch' : ['bootstrap'],
}
});
require(["jquery", "jquery-ui", "bootstrap", "dashboard", "application"], function($, jui, bootstrap, dashboard, application) {
$("#myTab a:first").tab("show");
}, function(err) {
console.log(err)
});
dashboard.js
define(function() {
var a = 10;
var Reload = {
dailyCharts : function() {
console.log("Daily Charts");
},
weeklyCharts : function() {
console.log("Weekly Charts");
}
};
var Display = {
none : function(node) {
console.log("none");
},
block : function(node) {
console.log("block");
}
}
});
application.js
define(["jquery", "dashboard"], function(jquery, dashboard) {
$("#dailyTab").click(function() {
dashboard.Reload.dailyCharts();
});
$("#weeklyTab").click(function() {
dashboard.Reload.weeklyCharts();
});
});
Can someone tell me what I have done wrong or what I can do to fix this issue. I accept my coding skills is not very good.
Any help on this is much appreciated. Thanks in advance