简体   繁体   English

通过ajax在新的浏览器选项卡中打开JQuery UI选项卡将直接显示ajax响应的HTML

[英]Opening JQuery UI Tabs in new browser tab via ajax will display the HTML of ajax response directly

I am currently upgrading from JQuery UI 1.8.14 to JQuery UI 1.10. 我目前正在从JQuery UI 1.8.14升级到JQuery UI 1.10。

With the v1.8.14 code, opening the tab with a new browser tab will reload the entire page, which activates the default tabs (ie. tabIndex=0) 使用v1.8.14代码,使用新的浏览器标签页打开标签页将重新加载整个页面,从而激活默认标签页(即tabIndex = 0)

I am encountering an issue with respect to JQuery UI Tabs and opening the tab in a new browser tab/window. 我遇到有关“ JQuery UI选项卡”的问题,并在新的浏览器选项卡/窗口中打开选项卡。 On my page, by right clicking the tab and selecting "open link in new tab". 在我的页面上,通过右键单击选项卡并选择“在新选项卡中打开链接”。 The tab content will be loaded via ajax 标签内容将通过ajax加载

The issue is that the new page will straight up display the HTML of the ajax response with no CSS styling, JavaScript, or anything. 问题在于,新页面将直接显示ajax响应的HTML,而没有CSS样式,JavaScript或其他任何内容。

This apparently is a design change by the JQuery UI team. 显然,这是JQuery UI团队的设计更改。 See below link: http://bugs.jqueryui.com/ticket/9363 参见以下链接: http : //bugs.jqueryui.com/ticket/9363

This seems to me a common issue but I am unable to find any solutions. 在我看来,这是一个常见的问题,但是我找不到任何解决方案。 Any suggestions for a workaround or a fix? 有任何解决方法或修复建议吗?

A really good example to demonstrate this issue would be the JQuery UI Tabs Demo page: http://jqueryui.com/tabs/ 演示此问题的一个很好的例子是JQuery UI Tabs Demo页面: http : //jqueryui.com/tabs/

Right click any tabs and select "open link in new tab". 右键单击任何选项卡,然后选择“在新选项卡中打开链接”。

Thanks for any help! 谢谢你的帮助!

In beforeActivate event, for each tab, store href as data object then set href as aria-controls. 在beforeActivate事件中,对于每个选项卡,将href存储为数据对象,然后将href设置为aria-controls。

    $(ui.newTab).parent().find("li a").eq(i).data("href.tabs",$(ui.newTab).parent().find("li a").eq(i).attr('href'));
    $(ui.newTab).parent().find("li a").eq(i).attr('href', '#'+$(ui.newTab).parent().find("li").eq(i).attr('aria-controls'));

In activate event, for each tab, set value from data object as href. 在激活事件中,对于每个选项卡,将数据对象中的值设置为href。

    $(ui.newTab).parent().find("li a").eq(i).attr('href', $(ui.newTab).parent().find('a').eq(i).data("href.tabs"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM