inside an开发者_运维百科 <\"ol\"> list." />
开发者

jquery-ui: trigger the select of an selectable ol-li-list

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" ...


Try:

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

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


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.


$("#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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜