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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -