I'm attempting to do a confirmation when a user changes a date using the date picker. Is it possible to get the previous value from the object model or will I need to roll my own?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There is not (afaik) but you can implement it pretty easily as this:
var datePicker = $("#date").kendoDatePicker({
change: function (e) {
var prev = $(this).data("previous");
var ok = confirm("Previous value:" + prev + ". Do you want to change?");
if (ok) {
$(this).data("previous", this.value());
} else {
datePicker.value(prev);
}
}
}).data("kendoDatePicker");
$(datePicker).data("previous", "");
Where I save previous value and then asks for confirmation.
See it running here.
Same approach but different implementation:
var datePicker = $("#date").kendoDatePicker({
previous: "",
change : function (e) {
var prev = this.options.previous;
var ok = confirm("Previous value:" + prev + ". Do you want to change?");
if (ok) {
datePicker.options.previous = datePicker.value();
} else {
datePicker.value(prev);
}
}
}).data("kendoDatePicker");
Where I extend kendoDatePicker.options
object with a previous
field and then I update it when it changes.