【问题标题】:jQuery UI tabs and multiselect href mishandling of base tagjQuery UI 选项卡和多选 href 对基标记的错误处理
【发布时间】:2012-11-17 12:03:15
【问题描述】:

我正在尝试解决最近对 jQuery UI 的更改带来的问题。 我正在使用 codeigniter、jquery 1.8.2.、jquery UI 1.9.1。

我总是把这个放在头部:

<base href="http://www.example.com/" />

所以我可以为我的图像、ajax 调用和其他原因使用集中的 url 方法。 问题是,jquery UI 也将使用它作为所有页面的所有锚点 href 的参考。例如,如果您在

中放置一个 jQuery UI 选项卡

http://www.example.com/view/users/1

第一个标签将加载主页的内容,因为它加载了

http://www.example.com/#路径

仅与多选 (http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/) 相同的问题,选中所有并取消选中所有会将您重定向到主页,因为

<a href="#">

将带你到http://www.example.com/#,而不是调用当前页面的 js 函数,例如http://www.example.com/view/users/1#

找到类似的票:

http://bugs.jqueryui.com/ticket/4941

http://bugs.jqueryui.com/ticket/8637

【问题讨论】:

标签: jquery jquery-ui href multi-select base


【解决方案1】:
$.fn.__tabs = $.fn.tabs;$.fn.tabs = function (a, b, c, d, e, f) {
var base = location.href.replace(/#.*$/, '');
$('ul>li>a[href^="#"]', this).each(function () {
    var href = $(this).attr('href');
    $(this).attr('href', base + href);
});
$(this).__tabs(a, b, c, d, e, f);
};

很奇怪。这对我有用。对于标签。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-11
    • 2020-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多