jquery - Newly added item to chosen.js make it selected automatically -
i have text field , button, user can enter name in text box , press button.
currently stands code adds item options available user select.
$("#btnaddcast").click(function () { $('#listactivities').append('<option>'+ $("#txtcast").val() + '</option>'); $('#listactivities').trigger('chosen:updated'); return false; });
what want / can't find within chosen.js documentation how make newly added item selected automatically know how such thing?
it looks selects still act normal selects. i'd select last item so:
$("#btnaddcast").click(function () { $('#listactivities').append('<option>'+ $("#txtcast").val()+ '</option>'); $('#listactivities :last').attr('selected','selected'); return false; });
Comments
Post a Comment