mootools 和原型冲突

发布于 2024-11-26 23:04:47 字数 665 浏览 1 评论 0原文

这是我的代码,它不起作用,如果我删除原型脚本文件,mootools 工作,如果我删除 mootools 原型工作!这是代码:

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

<script type="text/javascript">

            window.addEvent('domready', function(){
                var myMenu = new ImageMenu($$('#imageMenu a'),{openWidth:310, border:2, onOpen:function(e,i){alert(e);}});
            });
</script>

值得一提的是,当我尝试一次时,原型与 MT 一起工作,但原型中的 Ajax.Updater 仍然无法工作。

我确实检查了这里有关该问题的大部分主题,但仍然失败!

this is my code it keeps not work , if i remove the prototype script file , mootools work and if i remove the mootools prototype works !! this is code :

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

<script type="text/javascript">

            window.addEvent('domready', function(){
                var myMenu = new ImageMenu($('#imageMenu a'),{openWidth:310, border:2, onOpen:function(e,i){alert(e);}});
            });
</script>

Its important to mention that when i try once , prototype worked together with MT but Ajax.Updater in prototype still not work .

i did check most of topics here about the problem but still lose !

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

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

发布评论

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

评论(1

我的黑色迷你裙 2024-12-03 23:04:47

我不确定您为什么想要同时使用原型和 mootools。这肯定会构成对框架的滥用……选择一个并坚持使用它。如果您无法在其中之一之间进行选择,请从您甚至需要一个框架的基本假设开始,然后从那里决定哪一个适合您的需求。仅仅为了拥有而使用一个(或多个)是一个糟糕的计划。

这两个框架都是通过扩展 DOM 来实现其功能,因此存在冲突也就不足为奇了。两者都使用 $ 作为其扩展功能的入口点。当您堆叠框架时,您获得的功能重复量几乎阻止了它们的结合使用,更不用说加载大量不需要的代码时的额外开销了。

综上所述,您可以查看这篇文章 。这是 mootools 针对与其他框架的兼容性/冲突解决的建议。您会注意到,在文章的第一段中,作者给出了与我在这里相同的警告 - 不要堆栈框架。在极少数非常具体的情况下,这是您唯一的选择,否则您需要认真考虑为什么要采用这种方法。

I am not sure why you'd even want to use prototype and mootools together. This would certainly qualify as misuse of frameworks... pick ONE and stick with it. If you can't choose between one or the other, start with the base assumption that you even need a framework at all, then decide from there which one suits your needs. Using one (or several) simply for the sake of having it is a bad plan.

Both frameworks accomplish their functionality by extending DOM, so it isn't a surprise that there are conflicts. Both use $ as an entry point for their extended functionality. The amount of functionality duplication you get when you stack frameworks nearly precludes using them in conjunction, never mind the additional overhead in loading tons of code you don't need.

All that said, you can check out this article. This is mootools' recommendation for compatibility/conflict resolution with other frameworks. You will note that in the first paragraph of the article, the author gives the same warning I have here - don't stack frameworks. There are very few, highly specific circumstances where this is your only choice, otherwise you seriously need to consider why you're taking this approach.

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