mootools.js可以使用microsoftajax.js吗?

时间:2011-11-16 08:52:24

标签: javascript .net mootools

在一个页面上有mootools.js和microsoftajax.js脚本。基本上我使用microsoftajax.js所以我可以在脚本中使用类和委托等。客户在她的代码中使用Mootools。 似乎那些不能在一起因为我得到Type.createDelegate is not a function错误。 有解决方案吗?

更新: 我的脚本中抛出错误(使用microsoftajax.js的脚本) mootools是1.3.2版本

1 个答案:

答案 0 :(得分:1)

Type是一个MooTools构造,对于定义核心中的许多东西是必不可少的,包括类,对象,函数,数组,数字,字符串,日期,表(哈希)等。

它作为全局对象中的构造函数存在: https://github.com/mootools/mootools-core/blob/master/Source/Core/Core.js#L148

并且像这样使用(例如): https://github.com/mootools/mootools-core/blob/master/Source/Class/Class.js#L19

无论如何,对OP来说无关紧要。关键是,如果在其他脚本之后加载mootools,它覆盖Type。另一方面,如果您在脚本之前加载它并且不需要创建新的mootools类型,那么事情可能没问题。

您可以随时保存对它的引用并稍后恢复。

例如:

var MooTools.Type = this.Type;

... load ms one.
... do stuff with `Type.createDelegate` etc
... restore mootools one:

this.Type = MooTools.Type;

P.S。 wth是microsoftajax.js,为什么你不能使用mootools Request类呢?这些天你不能成为一个工具箱开发者。