waseem02 / jquery-asmselect

Automatically exported from code.google.com/p/jquery-asmselect
0 stars 0 forks source link

Manually triggering or calling add/remove #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Firstly congrats on asmselect, awesome plugin! Thank you.

I wasn't sure how to manually trigger the add function. The following code 
seems to work fine. Is there a way to call the triggerOriginalChange or 
selectChangeEvent functions? Or is this method the only way?

jQuery('select.asmSelect option[value='+VAL+']').attr
('selected', 'selected');
jQuery('select.asmSelect').change();jQuery('select.asmSelect').click();

I'm not too familiar with JS or jQuery, learning.. 

Calling the functions directly won't work because of the return index? :S 

Thanks again.

Original issue reported on code.google.com by jezth...@hotmail.com on 10 Sep 2009 at 2:48

GoogleCodeExporter commented 8 years ago
This works for me:

var id = 1;
$("#asmSelect1").val(id).click().change();

I need to call click() because of IE8.

Original comment by martin.m...@gmail.com on 1 Feb 2010 at 9:52

GoogleCodeExporter commented 8 years ago
Thanks, it appears that both of your solutions are correct. If you are dealing 
with a large list, you may want to look at giving your option tags ID 
attributes (and using them in your selector) so that you can retrieve them more 
quickly. But either works. 

Original comment by ryancram...@gmail.com on 10 Jul 2010 at 4:33

GoogleCodeExporter commented 8 years ago
Thanks, this helped me while stuck

Original comment by jacques....@gmail.com on 22 Sep 2010 at 8:47