javascript - 为什么包含 prototype.js 会破坏 jquery bbq 的功能?

标签 javascript jquery prototypejs jquery-bbq

我有:

    <!DOCTYPE html>
<html>
<head>

    <title></title>


<link rel="stylesheet" type="text/css" href="/temp/css/menu.css" />

<link rel="stylesheet" type="text/css" href="/temp/css/bottomchatdiv.css" />

<link rel="stylesheet" type="text/css" href="/temp/css/centercontent.css" />

<link rel="stylesheet" type="text/css" href="/temp/css/basics.css" />


    <script type="text/javascript" src="jquery-1.7.js"></script>

<script type="text/javascript" src="jquery.ba-bbq.js"></script>

<script type="text/javascript" src="jquery.ba-bbq-addtl.js"> </script>

<script type="text/javascript" src="prototype.js"></script>

<script type="text/javascript">
function getusto(anchorid) {
  $(anchorid).scrollTo();
} 
</script>

<script type="text/javascript" src="hide&show.js">

</script>




</head>
<body >


<div class="bbq">
  <div class="bbq-nav bbq-nav-top menu">
   <a class="mainitem menu_links" href="">Welcome</a>   <br> 

<a class="menu_links" href="#" onclick="getusto('welcome'); return false;">Welcome</a><br> 
<a class="menu_links" href="#" onclick="getusto('guidelines'); return false; ">Guidelines</a> 

<br>  
<hr style="width:48%"/>
<br>  



<a class="mainitem menu_links" href="#Regular-Visitors-&-Ops.html">Regulars & Ops</a> <br>

</div>

<br>  

<div class="bbq-content centercontent">

    <!-- This will be shown while loading AJAX content. You'll want to get an image that suits your design at http://ajaxload.info/ -->
        <div class="bbq-loading" style="display:none;">
      <img src="/shell/images/ajaxload-15-white.gif" alt="Loading"/> Loading content...
    </div>

    <!-- This content will be shown if no path is specified in the URL fragment. -->
    <div class="bbq-default bbq-item">

default welcome text here.

    </div>

  </div>


</div>


</body>
</html>

现在,问题是 Regular-Visitors-&-Ops.html 页面无法加载,但它正在加载!所以我修改了我的撤消操作,直到我发现不包括 prototype.js 让该链接通过 jquery bbq 的方式工作。

什么给了?如何让 prototype.js 和 jquery bbq 共存?我需要两者来做不同的事情..

要启动并运行它,您需要在同一目录中添加一个额外的 Regular-Visitors-&-Ops.html 文件,例如:

<!DOCTYPE html>
<head>
</head>
</body>
this is the additional file.
</body>
</html>

以及jquery,jquery bbq的两个脚本(我自己命名的一个),& prototype.js。

现在,如果您确实进行了设置 - 外卖原型(prototype)和 Regular-Visitors(...) 链接有效。问题是,我正在使用 prototype.js。所以要么我如何让这两个工作,或者更容易地,我如何实现 scrollTo 函数(不能使用 anchor ,因为 jquery bbq 占用了 anchor /哈希(例如“index.html# 中的“#welcome”欢迎”) WITHOUT USING PROTOTYPE.JS?应该有一个吧?

最佳答案

通过在 jQuery 之后包含 prototype.js,Prototype 将覆盖全局 $ 变量的值。你只需要使用:

var $j = jQuery.noConflict();

然后您可以在 jQuery 上下文中使用 $j 代替 $,在原型(prototype)上下文中使用 $。这是文档:http://api.jquery.com/jQuery.noConflict/ .

关于javascript - 为什么包含 prototype.js 会破坏 jquery bbq 的功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8907588/

相关文章:

jquery - 哪些RichFaces组件使用prototype,哪些使用jquery?

asp.net - 如何确保我的 href 优先于任何其他层,包括 flash?

javascript - 如何通过 Angular ui-router 在 ons-navigator 中设置 ons-sliding-menu?

javascript - HTTP 请求返回 200 OK 但没有响应内容

javascript - Knockout.js 显示/隐藏 block 可见性模式

asp.net - 一键执行客户端和服务器端代码?

javascript - jQuery 手机 : Position of external panel/always visible?

javascript - 在数组循环中绑定(bind) 'this'

jquery - 如何添加 jQuery .on click 到 Tablesorter th?

javascript - 在单独的文件中重写prototype.js中的getOffsetParent()函数