Kendo UI DatePicker-获取先前的值 [英] Kendo UI DatePicker - getting the previous value

查看:99
本文介绍了Kendo UI DatePicker-获取先前的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在用户使用日期选择器更改日期时进行确认.是否可以从对象模型中获取先前的值,或者我需要自己滚动?

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?

推荐答案

没有(afaik),但是您可以像这样很容易地实现它:

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.

此处看到它运行.

方法相同,但实现方式不同:

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");

我在其中用previous字段扩展kendoDatePicker.options对象,然后在其更改时对其进行更新.

Where I extend kendoDatePicker.options object with a previous field and then I update it when it changes.

这篇关于Kendo UI DatePicker-获取先前的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆