Edit Button which leaves the form open can't be used multiple times

Edit Button which leaves the form open can't be used multiple times

CapamaniaCapamania Posts: 233Questions: 81Answers: 5
edited February 2017 in Editor

I have two submit() buttons ... one which closes the edit form after submit() ... the other one which leaves the edit form open.

But ...the one which leaves the edit form open ('Edit') can only be triggered once. The button also stays focused. I guess it's because of the function. How can I use the 'Edit' button mutliple times? And how can I show a success message if the submit() was a success

    editor.edit( editRow, {
onComplete: 'none',
        buttons: ( [
            { 
                label: 'Edit',
                fn: function () {
                    this.submit();
                }
            },
              { 
                label: 'Edit & Close',
                fn: function () {
                    this.submit().close();
                }
            }
        ] )
    } );

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    this.submit().close();

    That's going to close the form before the submit is complete since the submit is async. Use the callback option of the submit method to provide a function that will close the form. Otherwise you won't see any validation error messages.

    Allan

  • CapamaniaCapamania Posts: 233Questions: 81Answers: 5

    Thanks Allan. Like this?

    fn: function () {
        var that = this;
        this.submit( function () {
            that.close();
        } );
    }
    

    And what about the other button ('Edit')? The one that should submit the data but leave the form open. I can only trigger it once as described above.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Yes, exactly like that.

    And what about the other button ('Edit')? The one that should submit the data but leave the form open. I can only trigger it once as described above.

    Are you then triggering a new edit or create? Once the submit is done, it assumes that the existing edit is complete and thus you'd need to start a new edit (even if the modal is left on the screen).

    Allan

  • CapamaniaCapamania Posts: 233Questions: 81Answers: 5
    edited February 2017

    Hi Allan ... yes I would like to edit again. How can I start a new edit? I tried this ...

    fn: function () {
        var that = this;
        this.submit( function () {
                that.edit();
        } );  
         }
    

    ... but I'm getting a 'Multiple values' message in the input field.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    You need to tell it what you want to edit though - the edit() method describes the parameters that it takes.

    Allan

  • CapamaniaCapamania Posts: 233Questions: 81Answers: 5

    I want to be able to edit the same values as before. I just don't want to close the from each time I do this. How can this be done?

    Best Regards

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Just pass in editRow in that case.

    Allan

This discussion has been closed.