Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

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?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.