Toggle modal enters in infinite loop

I have a modal and a dismiss button inside it that toggles the modal , when the button method property is set to 'submit' the modal keeps appearing infinitly and at each time i toggle the modal to hide it, it appears again, but when i set the method to 'ajax submit' it works correctly.

why is that ?

Modal toggles should ideally be set to Ajax submit. Is this a use case where you are trying to upload a file and that's why you're using Submit?

Muhamed Akl wrote:

I have a modal and a dismiss button inside it that toggles the modal , when the button method property is set to 'submit' the modal keeps appearing infinitly and at each time i toggle the modal to hide it, it appears again, but when i set the method to 'ajax submit' it works correctly.

why is that ?

Hi Muhamed,

My guess is that it's because the Submit method also run the Preparation *before* the action is called, and that is probably resetting the variables you're using in the action.

This is one of the reasons you should use the Ajax Submit method, because it bypasses the preparation, so you don't have to worry about managing postbacks.


Carlos Ribeiro da Fonseca wrote:

Muhamed Akl wrote:

I have a modal and a dismiss button inside it that toggles the modal , when the button method property is set to 'submit' the modal keeps appearing infinitly and at each time i toggle the modal to hide it, it appears again, but when i set the method to 'ajax submit' it works correctly.

why is that ?

Hi Muhamed,

My guess is that it's because the Submit method also run the Preparation *before* the action is called, and that is probably resetting the variables you're using in the action.

This is one of the reasons you should use the Ajax Submit method, because it bypasses the preparation, so you don't have to worry about managing postbacks.


Hi Carlos, 

I want to do just one correction. That is the prepration of the screen is not called before the action. It gets called after the action (if we are not redirecting to some other destination/ screen).


Mariano Picco wrote:

Modal toggles should ideally be set to Ajax submit. Is this a use case where you are trying to upload a file and that's why you're using Submit?

No I'm not uploading any files yet


Muhamed Akl wrote:

Mariano Picco wrote:

Modal toggles should ideally be set to Ajax submit. Is this a use case where you are trying to upload a file and that's why you're using Submit?

No I'm not uploading any files yet


Then, try it with Ajax Submit for now? If you need to upload files from that modal, that's a totally different beast.