By correction means I want to know if I'm doing this right.
It's working on my side i just want to know how to optimize the $.extend();
It looks pretty neat for me, but is there any ways to optimize it?
My thoughts: $.extend(arrayofelement, UIclient); So I don't need to repeat it every time I want to add a new function.
Here's my jQuery script:
(function () {
var UIopt = {
UserTrig : $(".user-x"),
Usertool : $(".user-ui-tools")
}
var UIclient = {
UIshow: function () {
return this.hover(function () {
UIopt.Usertool.show();
});
},
UIhide: function () {
return this.mouseleave(function () {
$(this).hide();
});
}
}
$.extend(UIopt.UserTrig, UIclient);
$.extend(UIopt.Usertool, UIclient);
UIopt.UserTrig.UIshow();
UIopt.Usertool.UIhide();
})(jQuery);
Plus, is this a correct way of writing an Object oriented jquery? If not can you show me how to do it?