Javascript 如何将切换和验证选项添加到x-editable?

Javascript 如何将切换和验证选项添加到x-editable?,javascript,x-editable,Javascript,X Editable,我使用x-editable作为内联编辑器 我想通过其他链接切换内联表单: $("#how").click(function(e) { e.stopPropagation() e.preventDefault() $("#com").editable({ 'toggle', validate: function(value) { if($.trim(value) == '') { return 'The content can not be

我使用x-editable作为内联编辑器

我想通过其他链接切换内联表单:

$("#how").click(function(e) {
  e.stopPropagation()
  e.preventDefault()
  $("#com").editable({
    'toggle',
    validate: function(value) {
      if($.trim(value) == '') {
        return 'The content can not be blank!';
      }
    }
  })
})

但它不起作用,我想知道如何同时传递切换和验证选项。

将选项声明和“切换”部分分开即可:

$("#how").click(function(e) {
  e.stopPropagation();
  e.preventDefault();
  $("#com").editable({
    validate: function(value) {
      if($.trim(value) == '') {
        return 'The content can not be blank!';
      }
    }
  });
  $("#com").editable('toggle');
});
希望这对其他人有帮助:)