dissecting mootools
dissecting mootools
本文关键字:mootools dissecting 更新时间:2023-09-26
我遇到了一个问题,需要在mootools
中内置一个功能来解决。于是我开始解剖它。这里有一个我感兴趣的函数 IframeShim.destroy
是这样的
destroy: function(){
if (this.shim) this.shim.destroy();
return this;
}
现在我不能理解的是什么是shim
。我特别想弄明白的是 Request.JSONP.cancel
它的代码如下
cancel: function(){
if (this.running) this.clear().fireEvent('cancel');
return this;
}
现在这个cancel调用clear
,其代码如下
clear: function(){
this.running = false;
if (this.script){
this.script.destroy();
this.script = null;
}
return this;
}
现在在这个清晰的函数中,我可以看到destroy()
,它把我带到shim
(见顶部的代码),我卡住了。所有这些函数都在mootools-more.js
帮助吗?
如果有人能提供Request.JSONP.cancel
的简单javascript实现就太好了它有JQuery
替代品吗? 被Request.JSONP.clear
方法调用的destroy不是IframeShim.destory
,它是mootools核心的一部分。来源:
destroy: function(){
var children = clean(this).getElementsByTagName('*');
Array.each(children, clean);
Element.dispose(this);
return null;
},
Element.dispose
所做的就是调用本地javascript DOM方法Node。removeChild从DOM中删除一个元素。
所以所有JSONP。cancel正在做的是查看是否通过Request.JSONP.cancel
添加了脚本DOM节点。如果是,它会通过removeChild从DOM中删除脚本元素。
重要的是它将running
标志设置为false。如果您查看Request.JSONP.success
,它在调用回调函数之前做的第一件事是检查running
标志是否设置为false,如果是,则立即返回。这有效地"取消"了执行。
如果你的意思是它是否取消HTTP请求,答案是不,它没有。
相关文章:
- Mootools:如何在点击时保持元素高亮显示并停止所有事件
- javascript mootools平滑滚动'x'像素数量
- mootools getElements failed
- mootools到窗体的QueryString
- mootools表单json post请求
- Mootools Asset with
- mootools点击:继电器没有在ipad/iphone上启动
- mootools 1.4.2和angular 1.3在ie8中配合得很好
- Mootools Selector issue
- mootools类型的函数将文本作为函数执行
- Mootools:拒绝设置不安全的标头“;连接”;
- 如何将对象引用传递到 mootools 中另一个对象的构造函数中
- 下个月开始MooTools Events Calendar
- 带有延迟的Mootools Spinner
- jQuery函数转换为MooTools
- 使用MooTools将类添加到元素的父级
- 当我添加Mootools时,外部JS库停止工作
- Mootools提交表单仅在通过ID选择表单时有效
- 使用Mootools对表格行进行排序
- dissecting mootools