Force AjaxDropdown to update

Feb 10, 2012 at 1:15 PM


Is there an easy way to force an AjaxDropdown to update itself? I use one of them in a page and, through some dialogs, I can create new items to append to the list. So, it would be very nice if there was a way to achieve that!

Thanks in advance,

Feb 10, 2012 at 4:06 PM

it updates on document ready an whenever the change event triggers on a parent element

so if you have:


and you do $('#some').change(); it will reload 

Feb 10, 2012 at 6:52 PM
Edited Feb 10, 2012 at 6:53 PM

Ok, I had already understood that. But if the AjaxDropdown is not related to any parent, I guess there's no way to force an update...

I changed the javascript a little bit in order to achieve that. Just in case someone finds itself in the same situation, I've changed the "this.ajaxDropdown" function (line 110 on 1.9 non-minified Awesome.js) to include this piece of code:

$("#" + o + "dropdown").bind('loadAjaxDropdown', function () { $ae.loadAjaxDropdown(o, p, url, true, keys, values, pkeys, pvals); });

Now, I can call $("#myPropertydropdown").trigger("loadAjaxDropdown"and it will do the trick!

Feb 14, 2012 at 11:18 AM

I refactored the code a little bit, and the whole function has become:

this.ajaxDropdown = function (o, p, url, keys, values, pkeys, pvals) {
        var $dropdown = $("#" + o + "dropdown");

        $dropdown.bind('loadAjaxDropdown', function (event) { var clear = (typeof event.clear == 'undefined' ? true : event.clear); $ae.loadAjaxDropdown(o, p, url, clear, keys, values, pkeys, pvals); });
        $dropdown.trigger({ type: 'loadAjaxDropdown', clear: false });

        $dropdown.keyup(function () { $(this).change(); }).change(function () { $('#' + o).val($dropdown.val()).trigger('change'); });

        if (p) $('#' + p).change(function () { $dropdown.trigger('loadAjaxDropdown'); });
        $.each(keys, function (i, k) {
            $('#' + k).change(function () { $dropdown.trigger('loadAjaxDropdown'); });
        //if keys foreach key change same