In my app, while page load i initiate my init
function for 3 things,
trigger and sending a page no. (i would like to pass page default as 1)
when trigger done, i want to hear that so i am listening
again, a user can insert / edit the page number (text box) so i am adding a listener to function.
but when function start i am consoling a object but i am getting result as undifined
.
what is wrong here:
var docLoader = function (params) {
window.container = window.container || $("#tenderContent");
return {
init : function () {
this.cachePages = {};
$(document).on("newMessage", this.onPageChange);
$.event.trigger({
type: "newMessage"
});
},
onPageChange : function (e) {
console.log(this.cachePages) //undefined why?
}
}
}
html page :
<script>
docLoader().init();
</script>
I am new to de-coupled approach any one help me with details please?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…