OnPreSubmit validations firing during remove()?

OnPreSubmit validations firing during remove()?

aveakaveak Posts: 15Questions: 0Answers: 0
edited July 2012 in Editor
Hi there,

I'm using some example code to create an inline Delete button. I've got some validation code for my form elements in the OnPreSubmit event in my editor. The removal code looks like this:

[code]
$('#users').on('click', 'a.editor_remove', function (e) {
e.preventDefault();

editor.remove( $(this).parents('tr')[0], 'Delete this user?', {
"label": "Confirm",
"fn": function () { this.submit(); }
}
);
});
[/code]

...the onPreSubmit event fires. This means that any user that hasn't been entered into the system under the same parameters as the validation can't be deleted. Is there a way to suppress the onPreSubmit event only in the instances when submit() is called during a remove()?

Replies

  • aveakaveak Posts: 15Questions: 0Answers: 0
    Ah, figured it out right after posting this. For onPreSubmit, the arguments are (e, data).

    The object "e" has a property "action". If this value of the action property is "remove", I just short-circuit the whole event and return true.
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Hi aveak,

    Good to hear that you found a solution to this. Just one moment to make - it should actually be 'data' (the second argument) which as the 'action' property. The first arguments the event that is being triggered (typically a mouse click), while the second one is what is going to be sent to the server (so it can be manipulated if needed).

    Regards,
    Allan
This discussion has been closed.