如何将函数传递给jquery UI选项卡的活动选项?



如何将函数传递给jquery ui tabs active option?

我可以像这样将函数传递给jquery uim选项卡激活选项

activate: function(event, ui){
localStorage.setItem("#" + $(this).context.id + "-current-index", $(this).tabs('option', 'active'));
}

如何使用活动选项获取这些值,下面的代码不起作用

active: function(event, ui){
localStorage.getItem("#" + $(this).context.id + "-current-index")
}

您可能需要查看.getItem()。我建议如下:

function getData(i){
return localStorage.getItem(i);
}

然后你可以像这样使用它:

active: function(event, ui){
ui.newPanel.html(getData("#" + $(this).context.id + "-current-index"));
}

更新

激活( 事件, UI (类型: 选项卡激活

激活选项卡后(动画完成后(触发。如果选项卡以前是折叠的,则ui.oldTabui.oldPanel将是空的 jQuery 对象。如果选项卡折叠,则ui.newTabui.newPanel将是空的jQuery对象。

另请参阅: https://api.jqueryui.com/tabs/#event-activate

ui.newPanel是jQuery对象,它表示">刚刚激活的面板。"因此,我们可以在该对象上使用.html()

.html( htmlString (

说明:设置匹配元素集中每个元素的 HTML 内容。

另请参阅: https://api.jquery.com/html/

最新更新