【问题标题】:Conflict Bootstrap, Prototype Js and Jquery冲突引导、原型 Js 和 Jquery
【发布时间】:2015-02-03 23:52:21
【问题描述】:

经过 7 天的搜索,在我尝试了不同的解决方案但没有奏效后,我想问: 我有一个带有原型 js、protaplasm、scriptaculous 和 jquery 和 Jquery-ui 的页面,它与 jquery 完美配合,没有冲突,直到我最近用 Bootstrap 下载了一个设计,麻烦来了。原型 js 功能不再起作用。原型 js 的 ajax 更新和 scriptaculous 的 inplaceeditor 不再起作用。 我已经尝试了大多数工作,但我并没有真正得到结果。有人有可行的解决方案吗?

【问题讨论】:

  • 我很早就尝试过,但没有成功。 JQuery 和 bootstrap 有效,但原型 js 和 scriptaculous 无效
  • 在尝试使用组件时是否会抛出任何 JS 错误?
  • js 错误未捕获异常:controls.js 需要包含 script.aculo.us 的 effects.js 库 ReferenceError: Effect is not defined dragdrop.js:8 TypeError: this.element.getStyle is not a function controls.js:498 TypeError: this.element.getStyle is not a function controls.js:498 TypeError: this.element.getStyle is not a function controls.js:498 TypeError: this.element.getStyle is not a function controls .js:498 TypeError: this.element.getStyle is not a function controls.js:498 TypeError: element.dispatchEvent is not a function prototype.js:7066 但我确实有效果.js
  • 也许我在这里遗漏了一些东西。如何用 require.js 引入原型 js。似乎在示例中你给我的prototype.js 不包括

标签: jquery ajax twitter-bootstrap prototypejs scriptaculous


【解决方案1】:

我找到了答案。避免 Jquery、Prototype js、protoplasm、twitter bootstrap 之间的冲突 首先我在 jquery 之后添加了 jquery noconlict

<script type="text/javascript">

    $.noConflict();

    </script>

我把每个jquery代码放在

之间
 jQuery( document ).ready(function( $ ) {
// Code that uses jQuery's $ can follow here.


///////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////

});

最重要的是,我打开了所有其他使用 jquery 的 js 文件,例如 bootstrap.min.js,然后我复制并粘贴了其中的代码

 jQuery( document ).ready(function( $ ) {
    // Code that uses jQuery's $ can follow here.


    ///////////////////////////////////////////////////////////////////////////////


    ///////////////////////////////////////////////////////////////////////////////

    });

我仍然遇到 TypeError 之类的错误:this.element is null controls.js with Firebug,但一切正常

【讨论】:

    猜你喜欢
    • 2010-09-13
    • 1970-01-01
    • 1970-01-01
    • 2011-03-08
    • 2010-11-01
    • 2012-01-09
    • 2011-01-29
    • 2013-05-28
    • 1970-01-01
    相关资源
    最近更新 更多