[jQuery] binding
[jQuery] binding
I'm trying to bind event focus to my onfocus, but the "this" is
conflicting, is there any alternative way of binding? Any ideas how i
should do is?
The script:
$(document).ready(function() {
$("input").searchProducts();
});
(function($) {
$.fn.extend({
searchProducts: function () {
new $.searchProducts(this);
}
});
$.searchProducts = function(obj){
this.obj = obj;
obj.focus(this.onfocus);
// .blur(this.onblur)
// .keyup(this.onkeyup)
// .keydown(this.onkeydown)
// .keypress(this.onkeypress);
this.focused = false;
}
$.searchProducts.prototype = {
onfocus: function(event) {
this.focused = true;
console.debug("focus");
},
onblur: function() {
console.debug("blur");
},
onkeyup: function(event) {
console.debug("keyup");
},
onkeydown: function() {
console.debug("keydown");
},
onkeypress: function(event) {
console.debug("keypress");
}
};
})(jQuery);