jquery.val setter patch for chosen #1027

Closed
RobinHerbots opened this Issue Feb 8, 2013 · 3 comments

Projects

None yet

3 participants

@RobinHerbots

Hi,

I wrote a little patch which fixes the issue that when setting the value with jquery.val you always have to trigger to get the change. Maybe you can include it in the cosen codebase

best regards,

Robin

jQuery.extend({
    valHooks: {
        select: {
            _set: $.valHooks.select.set,
            set: function (elem, value) {
                var values = jQuery.valHooks.select._set.call(this, elem, value);

                if ($(elem).hasClass("chosen")) {
                    setTimeout(function () {
                        $(elem).trigger("liszt:updated");
                    }, 0);
                }

                return values;
            }
        }
    }
});
@stof

I don't think we should patch jQuery in Chosen.

Thus, your solution may have a huge impact on performances as I think Chosen uses the setter itself

@RobinHerbots
@pfiller

Thanks for sharing, @RobinHerbots. I agree with @stof that this should not be a part of Chosen by default. Hopefully anyone else searching for this kind of solution will find this issue and be able to implement with your code, though!

@pfiller pfiller closed this Apr 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment