PreClose event only firing on first press of "update" button

PreClose event only firing on first press of "update" button

dmcglynndmcglynn Posts: 15Questions: 5Answers: 0

Hello

I'm attempting to run some code to conditionally prevent form-submission when the user presses the UPDATE button at the bottom of the editor-form, but the event seems to only fire once.

After I my code below returns false, it never seems to run again. It successfully prevents the form from closing, but the code never runs on subsequent presses of the update-button.

Is there something I have to run to re-bind the event?

Thanks,
David

    quoteEditor.on('preClose', function(e) {
        console.log( 'I AM RUNNING'  );
        if (quoteEditor.field('bus_quote.qpi').get() == 1) {
            console.log( 'Unable to update form with QPI of one! (submitted: '+ quoteEditor.field('bus_quote.qpi').get() +')');
            return false;
        } else {
            return true;
        }
    });

This question has an accepted answers - jump to answer

Answers

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

    The preClose event will not stop the form from submitting. You might want to have a look at preSubmit which will stop the form submitting using your conditional statement above.

    Having said that, your description suggests there is a bug in preClose which I will look into - but I don't think it is the correct event for what you want.

    Allan

  • dmcglynndmcglynn Posts: 15Questions: 5Answers: 0

    Hi Allan,

    You're absolutely correct - I was indeed looking for the functionality of preSubmit and not preClose. I thought I had tried preSubmit, and it didn't function as I expected, so I moved onto preClose. It must have been due to something else wrong with my code, so I wasn't testing it properly.

    Thanks for your help!

This discussion has been closed.