Create multiple rows and save text

Create multiple rows and save text

jonny.aa24jonny.aa24 Posts: 4Questions: 3Answers: 0
edited December 2021 in DataTables

I'm quite new to the API and so getting to grips with it slowly.

I'm trying to create a CRUD application and one of the main use cases of it is quick-create times.. reducing copy-pasting text etc... So my ideal scenario is to have a create button where I fill in the form, submit it, then have the form all intact still to submit again... and again and again... just editing the form fields as I go....

My create button has the following logic:

 { extend: "create", editor: editor,
              formOptions: {message: "", onComplete: 'none'},
              formButtons: ['Create',
                            { text: 'Submit and add another', action: function () { this.submit(); this.create(); console.log('creating...')} }
                           ],
              text: 'New Entry',
              className: 'new-entry-btn'
            }

This allows me to actually submit twice, but the 3rd time, it closes automatically. I'm not sure why this is the case?

Everytime I click 'Submit and add another' I it should submit and then create again right? Not close after the 2nd submit.

Also, the form fields go back to null after every submit..

Help appreciated :smile:

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    This example here might be worth looking, as it seems to do mostly what you're after. Here, it's keeping the form open, and re-using the "position" field in the next edit. THis might be able to get you going,

    Colin

Sign In or Register to comment.