I have a kendo grid with its dataSource, the grid has an editor dialogue with save button. I need to prevent the save button being double clicked. The onSave functions fire when the save button is clicked. I have a requestEnd event that fires when the save is to be re-enabled.
The problem: onSave1 fails 1 time in 100 (I think, its proving very difficult to test). It's based on adding an additional click handler, invoking preventDefault(). Is it fundamentally flawed?
Is onSave2 any better?
The problem: onSave1 fails 1 time in 100 (I think, its proving very difficult to test). It's based on adding an additional click handler, invoking preventDefault(). Is it fundamentally flawed?
Is onSave2 any better?
onSave1:
function
(e) {
$(event.srcElement)
.addClass(
"k-state-disabled"
)
.bind(
"click"
, disable =
function
(e) { e.preventDefault();
return
false
; })
this
.dataSource.one(
"requestEnd"
,
function
() {
$(
"[data-role=window] .k-grid-update"
).off(
"click"
, disable).removeClass(
"k-state-disabled"
);
})
}
onSave2:
function
(e) {
$(event.srcElement).removeClass(
".k-grid-update"
).addClass(
"k-state-disabled"
).addClass(
"disabledMarker"
);
this
.dataSource.one(
"requestEnd"
,
function
() {
$(
"[data-role=window] .disabledMarker"
).addClass(
".k-grid-update"
).removeClass(
"k-state-disabled"
).removeClass(
"disabledMarker"
);
})
}