New create window after submit()

New create window after submit()

pcsintjanbaptistpcsintjanbaptist Posts: 20Questions: 9Answers: 1

Situation sketch:
I made a table with a form (Datatable and Editor) In this form you have to choose a place and a person, both from a select and some additional data. This works perfectly fine, but now I got the feedback that the users would benefit greatly if they had a button "save and add new for the same place and person". Just to be clear: It's a create-form. A new record needs to be created each time they click the button, but the pop-up needs to re-open after saving and the "place" and "person" should be copied from the create-form that has been saved.

I tried to approach this in 2 ways:
1. Make the form submit without closing the pop-up and clear the fields that need to be re-filled in.

editorDiverseKosten.submit(
    function (result) {
        if(result.error){
            alert(result.error);
        } else {
            alert('It has been saved.');
            editorDiverseKosten.field('date').set('');
            editorDiverseKosten.field('quant').set('');
        }
    },
    function () {
        alert('Something went wrong.');
    },
    null,
    false
);

This works exactly the way I need it to, except for the fact that you can submit the form only once...

  1. I added a new editor.create() to the code above and that fixed the "submit only once" problem, but now the fields place and person don't want to set anymore. I've tried 2 versions. One with the .create() as the first attribute of .submit()
editorDiverseKosten.submit(
    function (result) {
        if(result.error){
            alert(result.error);
        } else {
            //if(confirm('De kost is succesvol toegevoegd. Je kan nu de volgende ingeven.')){
                editorDiverseKosten.create().set('place', 'KRSE').set('person', 239);
            //} else {
                //editorDiverseKosten.close();
            //}
        }
    },
    function () {
        alert('Something went wrong.');
    },
    null,
    false
);

In the second version I placed the line "editorDiverseKosten.create().set('place', 'KRSE').set('person', 239);" after the submit. The new pop-up launches in both cases, but the .set() doesn't work. (Which it does if I place it after the original form's .create(), so I know the code works. )

The first method shows the data I want, but only works once, and the second method always works but doesn't show the required data. Personally, I would expect that if the pop-up doesn't close, that the buttons of that pop-up would still work with all the visible data, but apparently not. Any ideas?

With kind regards,

Gloria

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586
    edited October 2020 Answer ✓

    I'd say go with something like this here. It's keeping the create form open and using the Position and Office values of the previous submission. You could do something like that,

    Colin

  • pcsintjanbaptistpcsintjanbaptist Posts: 20Questions: 9Answers: 1

    Worked like a charm :) Thank you very much!

This discussion has been closed.