Forums de discussion

using jquery instead of aui

Eric Soucy, modifié il y a 9 années.

using jquery instead of aui

Junior Member Publications: 65 Date d'inscription: 21/01/14 Publications récentes
Hello,
In my jsf portlet I'd like to use jquery instead of alloyui.
I am using liferay EE 6.2, are there issues I should be aware of?

Thank you
thumbnail
Kyle Joseph Stiemann, modifié il y a 9 années.

RE: using jquery instead of aui

Liferay Master Publications: 760 Date d'inscription: 14/01/13 Publications récentes
Hi Eric,
It should be fine to use jQuery in your JSF portlet. If you are using primefaces, icefaces, or richfaces, you should be able to use the version of jQuery that the component suite provides. The only potential issue that comes to mind is if you want to include a specific version of jQuery on the page. If you want to include a different version of jQuery on a page than the component suite supplies, then it might be possible to use jQuery.noConflict() to workaround conflicts.

- Kyle
thumbnail
David H Nebinger, modifié il y a 9 années.

RE: using jquery instead of aui

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Yeah, the only issue you have is two javascript frameworks loaded in the browser.

Might not be a big deal for the desktop, but you might want to test the impact to mobile.
Eric Soucy, modifié il y a 9 années.

RE: using jquery instead of aui

Junior Member Publications: 65 Date d'inscription: 21/01/14 Publications récentes
Hi thank you for the replies,

I'm having issues with alloyui regarding :

using a lightbox
on a mobile device, changing the orientation causes unexpected results that can move the light box out of view.
If the viewport changes dimensions, the lightbox dimensions do not follow.
problems with zoom in zoom out
if the iuser swipe, the page is scrolled, the lightbox is not "modal"


with tooltips (hints)
the opening/closing doesn't work consistently
touch ouside the tooltip does not close it.
positioning does not take into account the available space
unexpected behavior with re dimensionning and zooms

That is why we want to use jquery instead of alloyui
thumbnail
Jack Bakker, modifié il y a 9 années.

RE: using jquery instead of aui

Liferay Master Publications: 978 Date d'inscription: 03/01/10 Publications récentes
I have leaned towards using alloyui for coding within portlets but also definitely introduce jquery into themes for many marketing-like

overall document weight needs attention, but really... how heavy is a javascript library minimized compared to a photo of me rescuing a polar bear ?
Low Trux, modifié il y a 9 années.

RE: using jquery instead of aui

Junior Member Publications: 64 Date d'inscription: 06/11/14 Publications récentes
Kyle Joseph Stiemann:
Hi Eric,
It should be fine to use jQuery in your JSF portlet. If you are using primefaces, icefaces, or richfaces, you should be able to use the version of jQuery that the component suite provides. The only potential issue that comes to mind is if you want to include a specific version of jQuery on the page. If you want to include a different version of jQuery on a page than the component suite supplies, then it might be possible to use jQuery.noConflict() to workaround conflicts.

- Kyle


Hello Kyle, i was looking for information regarding this issue and find your answer. I'm using Liferay 6.2 and was trying to use jquery 2.1. Weird thing is the portal is not recognizing the $ when i code in jquery but when i change the same code replacing $ with jQuery it works. Im pretty sure it have something to do with what you are mentioning here but it's confusing since when i type a jQuery.fn.jquery on the browser console it tells me that im using JQuery 2,1. Will really appreciate if you can throw some light into this issue since even when i have read about for a long time i never understood the whole picture and i think it will really help me and other users.

Edit: I have realized that my portal is probably using two different versions of jquery (sadly we are migrating from a really old application in Liferay 4 and apparently we just have to deal with the fact that we need two dif versions of jquery installed). So i have been reading about jQuery.noConflict();. The thing is i want the whole portal to be able to recognize the $ expressions and dont have to use the JQuery statement. Is there any way to do this having in mind that i HAVE to use two versions of jquery, also we are using JQuery UI does this affecct the jquery UI ?

Many thanks !
thumbnail
David H Nebinger, modifié il y a 9 années.

RE: using jquery instead of aui

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Low Trux:
Weird thing is the portal is not recognizing the $ when i code in jquery but when i change the same code replacing $ with jQuery it works.


This is due to the noconflict() stuff in conjunction with AUI owning the $. When you use $, it's invoking AUI which doesn't have the same entry points you're expecting from jQuery. But, like you've seen, when you use jQuery instead it will work just fine.

No big deal for your own code, but the biggest problem you'll have is leveraging 3rd party plugins. Some plugins use jQuery, but others use $. In order to leverage those plugins, you'll have to use your own copy where you replace $ with jQuery.

Im pretty sure it have something to do with what you are mentioning here but it's confusing since when i type a jQuery.fn.jquery on the browser console it tells me that im using JQuery 2,1. Will really appreciate if you can throw some light into this issue since even when i have read about for a long time i never understood the whole picture and i think it will really help me and other users.

Is there any way to do this having in mind that i HAVE to use two versions of jquery, also we are using JQuery UI does this affecct the jquery UI?


No. You cannot use the $ at all under 6.2. You're either going to have to downgrade the 2.1-based code or update the older jQuery code.
Low Trux, modifié il y a 9 années.

RE: using jquery instead of aui

Junior Member Publications: 64 Date d'inscription: 06/11/14 Publications récentes
Thanks a lot for your answer David, that was really helpful to understand what's going on in my portal.