disable onPreSubmit function while using editor.remove

disable onPreSubmit function while using editor.remove

vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
edited February 2013 in Editor
Hi Allan,
Recently I noticed that error ' o.data.field-name ' undefined , which s being used in "events": {"onPreSubmit":{ }}. This happens only when I try to remove the row. How to fix it? Can I make onpresubmit function not to respond to delete row action , if so how?

Replies

  • allanallan Posts: 61,436Questions: 1Answers: 10,049 Site admin
    The data being set to the server for a `delete` action is different from the `create` and `edit` actions: http://editor.datatables.net/server/ .

    Probably what you want to do is check `o.action` in your event to see if it is `create` or `edit` - if so, perform whatever action is needed.

    Regards,
    Allan
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    Hi Allan,
    [code]
    "events": {
    "onPreSubmit": function ( o ) {
    if(o.action=="create"||o.action=="edit"){....
    [/code]
    Now it works fine for me. thank you very much.
    One more similar doubt.
    Is it possible to display one field only for create and some other field only for edit.

    [code]
    "fields": [{
    "label": "field1",
    "name": "field1",
    "type": "text"
    },
    {// to be used while creating only
    "label": "field2",
    "name": "field2",

    "type": "text"
    },
    {/////to be used while editing only
    "label": "field3",
    "name": "field3",
    "type": "text"
    }]

    [/code]

    Thanking you
  • allanallan Posts: 61,436Questions: 1Answers: 10,049 Site admin
    If you want the fields to be submitted in create as well, then use the `show` and `hide` methods to show and hide the files.

    If you don't want the fields to be submitted in create as well, just use a different instance of Editor which is configured with the fields that you want.

    Allan
This discussion has been closed.