所以我有一个漂亮的功能,可以通过以下形式检测我的变化:
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");
});
}
问题是此更改函数在IE中对非文本框输入(复选框和单选按钮)不一致地触发。当然在其他任何地方都能正常工作......
答案 0 :(得分:0)
这是我一直在努力的解决方法......
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
// IE6 Workaround: onchange events need a blur event to properly fire
$("#" + eForm + " :input[type='checkbox'], input[type='radio']")
.one("click", function() { $(this).get(0).blur(); })
// 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");
});
}