var SortingTable = new Class({
initialize: function(table, options) {
this.table=$(table);
this.tbody = this.table.getElement('tbody');
//...do alot of things here...
},
addTextInput : function(index,headid,options){
var trs = this.tbody.getChildren();
var trslen = trs.length;
var i=0;
var cell = null;
for(i=0;i<trslen;i++){
cell = trs[i].getChildren()[index];
cell.addEvent('dblclick', function (event){
alert(this.innerHTML); // i can see this is the cell here.
this.makeCellEditor(this); // how to access the parent object?
});
}
},
makeCellEditor : function(cell){
//make form and stuff here.
}
//...alot of more functions...
});
내 dblclick (이벤트) 함수에서 "부모"개체에서 선언 한 makeCellEditor 함수에 액세스하고 싶습니다. this
셀을 참조하는 이벤트 핸들러 내부부모 자바 스크립트 개체의 변수 및 메서드에 액세스하고 있습니까?
addTextInput: function(...) {
var self = this;
...
cell.addEvent('dblclick', function(event) {
self.makeCellEditor(this);
});
}
및 self
사용할 수 있습니다 :
감사를 읽을 수 있습니다! – jonaz