【问题标题】:Run a function before triggering x-editable在触发 x-editable 之前运行一个函数
【发布时间】:2016-05-02 22:32:49
【问题描述】:

如何在触发 xeditable 之前运行一些代码?并根据结果阻止默认行为?

$('#costumer_phone').editable({
    name: 'number',
    // THIS IS WHAT I WANT TO ACHIEVE
    onClick: function(e){
        if (var == true){
           e.preventDefault();
        }
    }
});

【问题讨论】:

    标签: javascript jquery twitter-bootstrap x-editable


    【解决方案1】:

    您可以使用init事件。请尝试如下所示。

    当元素被 $().editable() 方法初始化时触发。请 请注意,您应该在应用可编辑之前设置初始化处理程序。

    $('#costumer_phone').on('init', function(e, editable) {
         if (var == true){
               e.preventDefault();
            }
    });
    $('#costumer_phone').editable();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-04
      • 2018-05-04
      • 2021-05-29
      • 1970-01-01
      • 2014-12-09
      • 1970-01-01
      相关资源
      最近更新 更多