【问题标题】:Ajax im chat messenger conflict betn JQuery and PrototypeAjax im chat Messenger 冲突 betn JQuery 和 Prototype
【发布时间】:2013-03-14 13:37:58
【问题描述】:

我已经安装了 Ajaxim 3.4 ...独立运行正常,但我现有的站点出现问题 ....ajaxim 原型与 JQuery 冲突 ....所以停止我的 jquery 功能。

是否也有带有 JQuery 的 ajaxim 脚本......没有原型版本。

我们将不胜感激。

提前谢谢。

【问题讨论】:

  • ajaxim 似乎不需要 Prototype:ajaxim.com 你在用 Prototype 做别的事吗?
  • 否,如果我删除了prototype.js 文件..ajaxim 不起作用。
  • @René 的回答是正确的。那将是你最好的选择:)
  • 我试过用那个...但我无法修改整个站点 jquery scscript...:-p

标签: jquery chat prototype livechat


【解决方案1】:

Prototype 没有那么灵活,但 jQuery 可以设置为使用不同于 $ 的标识符:

var $j = jQuery.noConflict();

// Use jQuery via $j
$j(document).ready(function(){
    $j("div").hide();
});

// Use Prototype with $(...), etc.
$('someid').hide();

来源:http://docs.jquery.com/Using_jQuery_with_Other_Libraries

这样两个库可以并排使用。

现在,如果您自己的代码都使用 $ 符号进行 jQuery 调用,您仍然可以在自己的代码中使用该标识符,方法是将其包装在 onload-methods 中:

jQuery(function ($) {
    // Use jQuery with the standard $ sign in this scope,
    // even if it is assigned to prototype outside of this scope
    $('#id').whatYouWant();
});

【讨论】:

  • thnx ....我有 ajaxim 3.4.1 ...它使用原型....我无法在 JQuery 脚本中进行更改,因为我很难在整个站点中进行更改。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-08-03
  • 1970-01-01
  • 2012-03-21
  • 2012-02-29
  • 2011-02-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多