Jquery-ui: start selection of selected list ol-li

How can I trigger a select event inside some jquery code?

edit
I am using jquery-ui. Selectable items: <"li"> inside list <"ol">. (documentation: http://jqueryui.com/demos/selectable/ )

I cannot start it with "click" or "select" and "select" ...

+2


source to share


3 answers


Try:

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

      



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

0


source


Ok, now that you've edited, I'll try it too:

This is not an exact copy of the choice, but depending on your situation, it may 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 can call them explicitly right after that, or earlier, depending on the event.

0


source


$("#selectable2").selectable({
 filter: "div",
 selecting: function(ev, ui) {
 $(ui.selecting).text('selecting');
 },
 selected: function(ev, ui) {
 $(ui.selected).text('selected');
 },
 unselecting: function(ev, ui) {
 $(ui.unselecting).text('unselecting');
 },
 unselected: function(ev, ui) {
 $(ui.unselected).text('unselected');
 }
 });

      

DEMO

0


source







All Articles