36
Views
2
Comments
Solved
[SwaggerUI] Error in some buttons
swaggerui
Web icon
Forge asset by João Martins

When I'm trying to use "Try it out", "Authorize" or padlock buttons, the component show me a white screen and a loading animation.


In your example (https://joaomartins-os.outsystemscloud.com/SwaggerUI_Demo) it is possible to reproduce it by using the "Try it out" button.


I have checked the browser console and it has no errors.


Best Regards.


Screenshot_1.png
2015-11-25 17-16-51
João Martins
Solution

teresende wrote:

When I'm trying to use "Try it out", "Authorize" or padlock buttons, the component show me a white screen and a loading animation.


In your example (https://joaomartins-os.outsystemscloud.com/SwaggerUI_Demo) it is possible to reproduce it by using the "Try it out" button.


I have checked the browser console and it has no errors.


Best Regards.

Hi,

I've managed to fix this issue, please download the latest version to make use of it.

Just to give you the context of what was happening, the platform always adds the code we build into a <form> and once the swaggerUI script was generating <button>s, by default its behavior was to submit the form and therefore causing this annoying behavior.
To overcome this I've added this script

$(document).on("submit", "form", function (e) {
    e.preventDefault();
    return false;
})

to the SwaggerUI web block to prevent this to happen.

Please let me know if you have any questions.


Cheers,

João


2022-07-25 08-42-14
Tiago Resende

Hi João,

It works! Thanks for the reply and mainly for the explanation.

Regards,


Tiago


João Martins wrote:

teresende wrote:

When I'm trying to use "Try it out", "Authorize" or padlock buttons, the component show me a white screen and a loading animation.


In your example (https://joaomartins-os.outsystemscloud.com/SwaggerUI_Demo) it is possible to reproduce it by using the "Try it out" button.


I have checked the browser console and it has no errors.


Best Regards.

Hi,

I've managed to fix this issue, please download the latest version to make use of it.

Just to give you the context of what was happening, the platform always adds the code we build into a <form> and once the swaggerUI script was generating <button>s, by default its behavior was to submit the form and therefore causing this annoying behavior.
To overcome this I've added this script

$(document).on("submit", "form", function (e) {
    e.preventDefault();
    return false;
})

to the SwaggerUI web block to prevent this to happen.

Please let me know if you have any questions.


Cheers,

João




Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.