jQuery 与prototypeJS;大小儿童

发布于 2024-08-03 07:31:01 字数 516 浏览 2 评论 0原文

我目前在 magento 网上商店工作,它加载 PrototypeJS 作为框架。

然而,我有时需要 jQuery 来做一些自定义的事情。

jQuery 在原型之后加载并以 noConflict 模式运行。

现在,这是我的演示 HTML:

<div id="someID">
<div>child</div>
<div>child</div>
<div>child</div>
</div>

加载了一个外部 JS 文件并包含以下内容;

var $j = jQuery.noConflict();
$j(document).ready(function() {
    alert($j('#someID').children().length);
});

我的警报显示“1”(在任何选择器上),而预期为 3。

诡异的?!

I currently work on a magento webshop, which loads PrototypeJS as framework.

However i need jQuery at some point to do some custom stuff.

jQuery is loaded after prototype and runs in noConflict mode.

Now, here's my demo HTML:

<div id="someID">
<div>child</div>
<div>child</div>
<div>child</div>
</div>

An external JS file is loaded and contains the following;

var $j = jQuery.noConflict();
$j(document).ready(function() {
    alert($j('#someID').children().length);
});

My alert shows '1' (on any selector) where 3 is expected.

Weird?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷途知返 2024-08-10 07:31:01

好的,找到了解决方案:
Script.aculo.us 已过时,我更新到最新版本,一切都很好:)

请参阅:
http://www.magentocommerce.com/wiki/how-to/how_to_use_jquery_1 .2.6_lastest_with_prototype

OK, found the solution:
Script.aculo.us was outdated, i updated to the latest version and everything is just fine :)

See:
http://www.magentocommerce.com/wiki/how-to/how_to_use_jquery_1.2.6_lastest_with_prototype

伤感在游骋 2024-08-10 07:31:01

在测试文件中仅使用该代码,我得到了正确的值。是否有可能使用其他代码从 DOM 中删除或重新排列其他元素?

Using only that code alone in a test file, I get the proper value. Is it possible that the other elements are being removed from or rearranged in the DOM using some other code?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文