I have a Protoype in my project as follows:
(function($) {
$.fn.observerPages = function(pageNo) {
return new ObserverPage($(this), pageNo);
};
function ObserverPage(Parent, pageNo) {
try {
this.parent = Parent;
this.isInitialized = false;
this.timer = -1;
this.highChart = [];
} catch (e) {
}
}
ObserverPage.prototype = {
initialize: function(url) {
isInitialized = true;
},
update: function(controllerurl) {
if (isInitialized == true) {
//Update
}
},
startTimer: function(url, interval) {},
stopTimer: function() {}
};
})(jQuery);
This initiates a page that is hooked with an observer and gets data from an ajax service at a defined interval.
What I require is to put an event in this where the user can put a function when this.isInitialized becomes true.
Currently I am using it like this.
var page = $("liveDiv").observerPages(2);
page.initialize("http://localhost:5549/GetLatestNews");
page.update("http://localhost:5549/GetLatestNewsData");
I want an event that the user can handle when isInitialized gets true and can be used like this
page.onInitialize(function(){
//User writes his function
});
How can I do that?