views:

558

answers:

3

How can I trigger the select-event inside some jquery code?

edit:
I'm using jquery-ui selectable. The selectable items are <"li"> inside an <"ol"> list.
(documentation: http://jqueryui.com/demos/selectable/)

I cant trigger it by "click" nor "selecting" nor "select" ...

A: 

Try:

$('#elem_id').select();

http://docs.jquery.com/Events/select

Alex Sexton
this would have helped if I wouldn't have asked my question wrong.. sorrysee the edit
Frankie-T
A: 

Ok, now that you've edited, I'll try this one as well:

This isn't an exact replica of a select, but depending on your situation, could do what you need.

var desired_option_index = 1;
$('ol#myOptions li').eq(desired_option_index).addClass('ui-selected');

If you have callback functions that are important, you could call those explicitly right afterward, or before, depending on the event.

Alex Sexton
this adds only the css-class, but doesnt trigger the actual click
Frankie-T
A: 

anyone a solution for this one? i have the same problem.

Dazz