您好我有這樣的代碼片段,我需要得到具有MooTools的1.3工作:如何將從MooTools 1.2創建的函數替換爲1.3?
this.fn = function (e, cal) {
var e = new Event(e);
var el = e.target;
var stop = false;
while (el != document.body && el.nodeType == 1) {
if (el == this.calendar) { stop = true; }
this.calendars.each(function (kal) {
if (kal.button == el || kal.els.contains(el)) { stop = true; }
});
if (stop) {
e.stop();
return false;
}
else { el = el.parentNode; }
}
this.toggle(cal);
}.create({
'arguments': cal,
'bind': this,
'event': true
}); <-- THIS CREATE METHOD DOES NOT WORK
有人可以幫助我白衣呢?
這是我所看到過,我會尋找另一個更重發的腳本; O) – 2011-03-18 11:06:36
你嘗試過'Function.from'用綁定?可能http://jsfiddle.net/dimitar/7YNK7/儘管你真正需要的是http://jsfiddle.net/dimitar/7YNK7/1/IMO。 bindWithEvent不見了...... – 2011-03-18 11:41:42
另外,不要使用'new Event(e).stop()',而是使用'e.stop'並首先檢查'e && e.stop'(如果你使用'.fireEvent )'手動,依賴'e.target'也應該儘可能地避免,因爲它使得'fireEvent()'更加困難(你需要傳遞一個包含'target:someEl'的虛擬事件對象作爲屬性) – 2011-03-18 11:56:27