1
所以,我有我的,檢測的變化,我在窗體漂亮的函數:IE6:jQuery的變更事件分配控制
function EnableChangeDetection(eForm) {
// One of the nice benefits of this change detection is that we don't have
// to keep an additional array of previous values to compare. Also we
// don't have to worry about applying global unformatting for comparison
// and formatting back
// For each input control
$("#" + eForm + " :input")
// Add a change event that will trigger if the form has been changed
.one("change", function() {
$.jGrowl("Change detected...");
// Flag the form with an IsDirty class
$("#" + eForm)
.attr("class", "IsDirty")
// Now remove the event handler from all the elements
// since you don't need it any more.
$("#" + eForm + " :input")
.unbind("change");
});
}
的問題是,這種變化的功能火災不一致的非文本框輸入(checkboxs和電臺按鈕)在IE中。做工精細其他地方當然...
透徹的解釋是在這裏:http://www.quirksmode.org/dom/events/change .html – 2009-12-18 18:39:08
我建議你忘記IE6。有一個腳本告訴用戶更新到一個更新的IE瀏覽器。當我開發網頁時,我從不考慮IE6 :) – Steven 2009-12-18 18:47:22
我認爲你不需要調用'unbind'。這是'bind'的對應物。無論如何,你正在使用只有一次的「one」。 – RamboNo5 2009-12-18 19:00:43