单击按钮时更改活动选项卡
我有两个由 jquery-ui 生成的选项卡。我在 Tab1 中执行某些操作,然后单击按钮,就会有一个 AJAX 调用在 Tab2 中显示结果。
所以我想更改按钮单击时的活动选项卡(ajax调用完成后)。我可以这样做吗?
我创建了一个 jsFiddle here
我尝试了 onclick='$("#tabs -2").trigger("点击") '>
但它没有做任何事情。
I have two tabs generated by jquery-ui
. I do something in the Tab1 and on a button click, there is an AJAX call which displays the results in Tab2.
So I want to change the active tab on button click ( after the ajax call finishes ). Can I do so?
I've created a jsFiddle here
I tried onclick='$("#tabs-2").trigger("click")
but it didn't do anything.
'>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
作为信息(以防有人稍后偶然发现这一点并在 select 方法上遇到错误) - 在 jQuery-UI 1.9+ 中, select 方法已被弃用。
(http://jqueryui.com/upgrade-guide/1.9/#deprecated-select-method)
使用option方法,示例:
As info (in case someone stumbles upon this later and gets an error on the select method) - In jQuery-UI 1.9+, the select method was deprecated.
(http://jqueryui.com/upgrade-guide/1.9/#deprecated-select-method)
Use the option method, example:
使用
onclick='$("#tabs").tabs( "select", "tabs-2" )'
http://jqueryui.com/demos/tabs/#method-select
Use
onclick='$("#tabs").tabs( "select", "tabs-2" )'
http://jqueryui.com/demos/tabs/#method-select
js小提琴
http://jsfiddle.net/maheshvemuri/M7Fdu/
< strong>这是代码的 JS 部分:
以下是要添加到选项卡 div 中的“a href”标签
示例:
js fiddle
http://jsfiddle.net/maheshvemuri/M7Fdu/
Here is JS part of the code:
Here are the "a href" tags to be added in your tabs div
Example:
您必须对“li”内的“a”进行触发器调用,而不是像完成的那样直接调用选项卡“div”。
示例:
http://jsfiddle.net/Tf9sc/152/
You have to make the trigger call to "a" inside the "li", not direct to the tab "div" like it's done.
Example:
http://jsfiddle.net/Tf9sc/152/
您也可以尝试
这样做,因为您无法在就绪模式下触发调用 tabs() 。 document.ready 早于 window.load 执行。
Also you can try
that's because you cannot trigger call the tabs() in ready mode. document.ready is executed earlier than window.load.