Reputation: 1328
I need to call the jquery function from one .js file to another .js file. please see my code sample here. I want call a slide()
method from ChartCallback.js file.
var Accordian = (function () {
"use strict";
var Accordian = {
slide: function () {
debugger;
alert("event trigger");
}
};
return Accordian;
}());
this.FocusChart = ChartCallBack.FocusChart;
ChartCallBack.FocusChart = function () {
console.log(window);
console.log(Accordian);
Accordian.slide(); //while call this "slide" is undefined exception thrown
}
I checked "Accordian"
it was initialize with slide()
method before load the ChartCallback.js
.
What i did wrongly here. anyone could solve my problem.
Upvotes: 2
Views: 173
Reputation: 1104
As long as you include both files in one html document, this should work fine. Just be aware that the order of inclusion will matter here.
<script type="text/javascript" src="ChartWebControl.js"></script>
<script type="text/javascript" src="ChartCallBack.js"></script>
In essence this will load both scripts into the same page.
If you meant to communicate with two separate html files, this is not possible without some kind of server communication.
Upvotes: 2