繁体   English   中英

我在jquery ui工具提示和bootstrap.js中面临冲突,因此我将以下解决方案作为建议的新别名并收到错误:-

[英]I am facing conflict in jquery ui tooltip and bootstrap.js, so I put the below solution as suggested for new alias and getting the error :-

别名更改-:

$.widget.bridge('uitooltip', $.ui.tooltip);

现在在使用新别名调用jQuery工具提示时遇到错误:

未捕获的错误:初始化前无法在uitooltip上调用方法; 试图调用方法'option'...

这是我正在使用的代码片段:-

$(this).uitooltip( "option", "content", ""+ $(this).attr("data-content") );

数据内容效果良好并评论以上部分效果良好的地方。

事物的顺序至关重要。

<script src="js/jquery-1.11.1.js"></script>
<script src="js/jquery-ui.js"></script>
<script>
    // handle jQuery plugin naming conflict between jQuery UI and Bootstrap
    $.widget.bridge('uibutton', $.ui.button);
    $.widget.bridge('uitooltip', $.ui.tooltip);
</script>
<script src="js/bootstrap.js"></script>

首先必须是jQuery UI,然后是$.widget.bridge的调用,然后是bootstrap.js的包含

然后要初始化工具提示,您将使用如下所示的内容:

$(document).ready(function(){
    $('mySelector').each(function(ind, ele){
       var $this = $(this),
           myContent = $this.attr("data-content");
       $this.uitooltip({"content":myContent});
    });
});

原始方法的问题在于,它是在初始化窗口小部件使用方法来设置选项,而不是在初始化时用于设置选项的方法。 初始化的正确方法如下:

$(this).uitooltip({ "content": ""+ $(this).attr("data-content") });

暂无
暂无

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

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