Foren

JQuery Conflict with Liferay 7 theme

thumbnail
William Gosse, geändert vor 6 Jahren.

JQuery Conflict with Liferay 7 theme

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
I think I'm having a JQuery conflict between the JQuery in Liferay 7 themes and JQuery being used by my portlets. I'm assuming the JQuery in the theme is being provided by the bootstrap 3. Our portlets are legacy Spring MVC portlets being migrated from our existing 6.2 installation.

I was wondering if anyone as a best practice for handling this kind of conflict.
thumbnail
William Gosse, geändert vor 6 Jahren.

RE: JQuery Conflict with Liferay 7 theme (Antwort)

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
We tried this fix which seems to have cured our problem:
http://www.learnandpost.com/2016/10/jquery-ui-with-liferay-7.html

Would still like to here any other suggestions as well.
Gunnar Brinkmann, geändert vor 6 Jahren.

RE: JQuery Conflict with Liferay 7 theme

Junior Member Beiträge: 53 Beitrittsdatum: 02.12.11 Neueste Beiträge
William Gosse:
We tried this fix which seems to have cured our problem:
http://www.learnandpost.com/2016/10/jquery-ui-with-liferay-7.html

Would still like to here any other suggestions as well.


I'd say that it's always dangerous / undefined to use different versions of a js framework in one html document.

One of multiple includes always wins regarding identical method signatures.

We're using primefaces in our portlets (same version in all portlets) and didn't have problems so far (crossing fingers).

An option could be a definition like "my portlet doesn't contain jQuery because the portlet container already imports jQuery". In this case the portlet should use a version of jQuery UI that is compatible with the jQuery version imported by the theme. As far as I know jQuery must be explicitely included when using jQuery UI, so it could be enough just to remove your jQuery include from the portlet view.

Another option could be (not sure, not tested) to provide "your" jQuery as an osgi module with some custom osgi module name. But when method calls are not namespaced (cannot be prefixed or are not automatically prefixed with this osgi name), this would be no option, the problem would stay the same (one of multiple includes wins).