Problem selecting option by value

88 views
Skip to first unread message

Tiago Farinon

unread,
Sep 25, 2015, 10:24:08 AM9/25/15
to select2
Hi guys!

I have the following select:

<select name="BillingServiceId" id="BillingServiceId" class="span12 select2 select2_sample1">
 
<option>...</option>
 
<option value="AC">AC</option>
...
 
<option value="RS">RS</option>
 
<option value="RO">RO</option>
 
<option value="SC">SC</option>
</select>

and i'm trying to select one option filling the value propriety like this:

$('#BillingServiceId').val("RS");

or this:

$('#BillingServiceId>option[value="' + "RS" + '"]').prop('selected', true);

Actually It realy changes the value of the select.. My problem is that the selected option don't appear in the select while i don´t click in the select.


  this is the way it looks while theres no value selected



this is the way it looks when i choose one option by click


  this is the way it looks when i fill the select value using jquery (it should looks like the case when i select a value by click..)



What can i do? Im ai doing something wrong?


Tks!!!


Kevin Brown

unread,
Sep 25, 2015, 5:38:27 PM9/25/15
to select2
Whenever you change selections outside of Select2, you need to trigger the `change` event so Select2 can react to them.

--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at http://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages