开发者

jquery ui tabs - is there a way to pass custom arguments to the event handler?

I am using jquery tabs to generate tabs for my page. On tab selection a event handler -

$("#tabs").bind('tabsselect', function(event, ui) {
 // some code
});

I want to know of a way to pass my custom arguments to the event handler function. Or any other way by which I could send those arguments with 'ui' object or 'event' object.

Th开发者_Python百科anks Saarthak


found the answer through jquery forum.

Posting it here for anyone looking for the answer -

You could use the event data mechanism of the bind function:

$('#tabs').bind('tabsselect', {abc: 'def'}, function(event, ui) {
      alert('here ' + event.data.abc);
});

Or just place your options in an accessible variable:

var tabOptions = {collapsible: true};
$('#tabs').tabs(tabOptions).bind('tabsselect', function(event, ui) {
      alert('here ' + tabOptions.collapsibe);
});

Hope this helps someone.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜