I am setting a value to input box and trigger to hear the change. I would also like to always hear the input change, and for that I made this function.
Can any expert please verify the way I did is correct? Or is it further tune-able?
var page = function () {
return {
init : function () {
var input = $("#pNo");
$(document).on("pageChange", this.onPageChange.bind(this));
$(input).val(1).trigger({type:'pageChange',element:input});
$(input).bind("change paste keyup",function() { $.event.trigger({type: "pageChange", element:input})});
},
onPageChange : function (e) {
console.log($(e.element).val());
}
}
}();
page.init();