swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Running Swagger UI with jQuery No-conflict

Open grantpalin opened this issue 11 years ago • 5 comments

Swagger UI doesn't work in cases where jQuery is loaded in no-conflict mode - the $ references in swagger-ui.js cause $ is not a function errors. The same setup works when jQuery is loaded normally, but I can't rely on that.

I know that this can be worked around by enclosing the code in a self-executing function and passing in the jQuery object as $, but I'm hesitant to modify dependency code. My other option may be to try running Swagger UI in an iframe, where the parent page setup won't apply.

Please consider updating Swagger UI to work when jQuery is in no-conflict mode.

grantpalin avatar Oct 02 '15 19:10 grantpalin

I would like to see this resolved as well. I did some digging and I believe the problem is in jquery-ba.bbq. We have a custom template that includes jquery 2.1. And that causes the Swagger UI to fail with this error. And jquery-ba.bbq appears to bot work with jquery 2.1 because of removed functions ($.param.fragment is not a function).

osbornk avatar Jan 28 '16 20:01 osbornk

+1

jamesxabregas avatar Apr 06 '16 05:04 jamesxabregas

I am working on this too. I want to be able to host this in an app that is using JQuery 2.x in noConflict mode.

The jquery-ba.bbq issue can be worked around by adding jQuery migrate. jQuery migrate will add back in the deprecated methods to support older dependencies like jquery-ba.bbq.

But, I am facing the same enclosure issue. I am going to go ahead and modify it, but +1 for wrapping everything in an enclosure.

jasonyarrington avatar May 10 '16 23:05 jasonyarrington

This should be resolved in 3.0. Please reopen otherwise.

webron avatar Mar 20 '17 22:03 webron

Good to know. I worked around the issue by using an iframe to contain the spec.

grantpalin avatar Mar 20 '17 23:03 grantpalin