4

我使用的alertifyjs很棒,但我有一个小问题想解决,也许在你的帮助下。

使用提示组件我想强制用户在输入字段中写一个“原因”,老实说我不知道​​该怎么做......

其实我的代码是这样的:

  alertify.prompt(
        'Warning!',
    'Are you sure you wish to CANCEL the order?',
    'Enter reason please...',
    function (e, reason) {
      // my code on confirm...
    },
    function () {
        return;
    }
  );

我希望你能帮忙。

4

1 回答 1

2

该文档显示以下内容:

alertify.prompt(
    'Warning!',
    'Are you sure you wish to CANCEL the order?',
    'Enter reason please...',
    function (e, reason) {
       if( reason == '' ) { 
           e.cancel = true;
       }
      // my code on confirm...
    },
    function () {
        return;
    }
  );

http://alertifyjs.com/prompt/onok.html 要防止对话框关闭,请设置 closeEvent.cancel = true 或让您的回调返回 false 。

于 2016-01-22T16:09:23.283 回答