var ioko = Class.create();//什么意思?
var cheboxarr= new Array();
ioko.BoundCheckboxMaster = Class.create({//什么写法?什么意思?
initialize: function(clientId)//什么写法?什么意思?
{
this.childArray = new Array();
this.element = $(clientId);
this.element.observe("click", this.onClick.bindAsEventListener(this));//observe()什么意思??
this.element.__boundcheckbox=this;
}, registerChild : function(child) {
//this.childArray.push(child);
cheboxarr.push(child);
},
onClick : function(event)
{
for ( var child in cheboxarr) {
// TODO: we seem to register everything twice
// but the second set are not valid (child.element is null)
if(typeof(cheboxarr[child].element)=='object')
cheboxarr[child].element.checked=this.element.checked;
}
return false;
}
});大哥们 指点小弟一下 感激
var cheboxarr= new Array();
ioko.BoundCheckboxMaster = Class.create({//什么写法?什么意思?
initialize: function(clientId)//什么写法?什么意思?
{
this.childArray = new Array();
this.element = $(clientId);
this.element.observe("click", this.onClick.bindAsEventListener(this));//observe()什么意思??
this.element.__boundcheckbox=this;
}, registerChild : function(child) {
//this.childArray.push(child);
cheboxarr.push(child);
},
onClick : function(event)
{
for ( var child in cheboxarr) {
// TODO: we seem to register everything twice
// but the second set are not valid (child.element is null)
if(typeof(cheboxarr[child].element)=='object')
cheboxarr[child].element.checked=this.element.checked;
}
return false;
}
});大哥们 指点小弟一下 感激
<script>
/**
* 说明:这是框架prototype.js中的写法,没接触过这个框架,仅供参考
*/
var ioko = Class.create();//什么意思?(创建一个类基赋值给ioko)
var cheboxarr= new Array();
ioko.BoundCheckboxMaster = Class.create({//什么写法?什么意思?(给增加属性ioko、方法)
initialize: function(clientId)//什么写法?什么意思?(框架中初始化方法)
{
this.childArray = new Array();
this.element = $(clientId);
this.element.observe("click", this.onClick.bindAsEventListener(this));//observe()什么意思??(貌似是绑定事件,相当于:ie中的attachEvent,ff中的document.addEventListener)
this.element.__boundcheckbox=this;
}, registerChild : function(child) {
//this.childArray.push(child);
cheboxarr.push(child);
},
onClick : function(event)
{
for ( var child in cheboxarr) {
// TODO: we seem to register everything twice
// but the second set are not valid (child.element is null)
if(typeof(cheboxarr[child].element)=='object')
cheboxarr[child].element.checked=this.element.checked;
}
return false;
}
});
</script>
prototype的东西
Class.create();相当于调用Class对象的create方法
Class.create({这里是添加函数或属性,和apply函数很像。就是往里面写东西
this.element.observe("click", this.onClick.bindAsEventListener(this));//给当前元素绑定click事件