SAPUI5教程——实现倒计时控制Button是否可以点击效果

来源:互联网 发布:java包名可以大写 编辑:程序博客网 时间:2024/06/03 09:52

前言

如果在SAPUI5开发中,我们想实现一个倒计时控制Button是否允许点击的例子,我们可以这样做:

方法

下面是一个自定义Dialog, 然后控制Button倒计时显示的方法示例:

    onConfirmDialog: function (title, message, confirmText, cancelText, successFn, cancelFn) {            var enabled = false;            var okButton = new Button({                    enabled: enabled,                    text: confirmText + " (3)",                    press: successFn                });            // the follow code it is for dialog button count 3 2 1, then enabled it            var i = 3;            var interval = jQuery.sap.intervalCall(1000, this, function(){                okButton.setText(confirmText + " (" + i + ")");                if(i === 0){                    okButton.setText("OK");                    okButton.setEnabled(true);                      jQuery.sap.clearIntervalCall(interval);                }                i--;            });            var dialog = new Dialog({                title: title,                type: "Message",                content: [                    new Text({ text: message})                ],                beginButton: okButton,                endButton: new Button({                    text: cancelText,                    press: cancelFn                }),                afterClose: function() {                    dialog.destroy();                }            });            // when we execute the setText, the footer of dialog' theme will be change (become dark) so I use the custom css            dialog.addStyleClass("customerDialogFooter");            dialog.open();            return dialog;        },

更多全面的教程,请查阅本人录制的SAP Fiori 2.0视频教程

http://edu.csdn.net/course/detail/5046

原创粉丝点击