harvesthq/chosen — Issue #360: Chosen liszt:updated not triggering correctly
Author: Rondel
Created: 2011-11-21 20:58:11+00:00
State: open

I'm using ASP.Net MVC3 and the Chosen jQuery widget. I have used the chosen widget on many occasions before but this is the first time I have used it on a dynamically changing select field. I have a multiple select list that is updated by this method

function loadGroups() {

$.getJSON("/Process/ShowGroups", null, function (data) {
var selectList = $("#groupsList");
selectList.empty();
$.each(data, function (index, optionData) {
var option = $('
').text(optionData.Text).val(optionData.Value);
selectList.append(option);
});
});
$("#groupsList").trigger("liszt:updated");
}

Without using chosen it works as expected. However, when I use chosen and try to trigger the liszt:updated event, it doesn't update the select list and I have to refresh the page to see any changes.

@Html.ListBox("groups", (SelectList)ViewBag.processGroup_drpdwn, new { id = "groupsList", style = "padding-left:5px;padding-right:20px;width:208px;" })

and I call the chosen method at the bottom of the page

Here are the files I add to the page

Am I missing some aspect of triggering the event? I can't get the event to work correctly in any of my browsers (Chrome, IE et.)