why
why

Reputation: 24851

How to add both toggle and validate options to x-editable?

I use x-editable as inline editor http://vitalets.github.io/x-editable/docs.html

I want to toggle inline form by other link:

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

But it does not work, I want to know how to pass both toggle and validate option.

Upvotes: 2

Views: 1226

Answers (1)

sonlexqt
sonlexqt

Reputation: 6469

Seperate the options declaration and the 'toggle' part will do the trick:

$("#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');
});

Hope this is helpful for others :)

Upvotes: 3

Related Questions