Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Not Relevant
Issues with jQuery conflicts, functions not working, etc.
August 17, 2009 6:31 PM
Answer

Not Relevant

Rank: New Member

Posts: 1

Join Date: February 1, 2009

Recent Posts

I am having a very strange issue with jQuery and hoped that someone might have an idea or may have seen this before.

Basically the problem is thus:

* Liferay has a folder called jquery, which contains a whole bunch of different .js files - jquery (version 1.2.6), most of the ui files (but not all) and most of the effects files (but again, not all)
* I tried to get a very basic slide effect happening using the jquery files that were already in place, but to no avail
* I linked my own copy of ui.slider.js, but it still didn't work
* I linked my own copy of jquery.js and ui.slider.js, and the slider worked, but only if their copy of jquery was also still linked
* After I did this, none of the Liferay functionality worked - things like draggable divs, various overlays, editable text, cookies, etc.

So in short - if I link my own copy of jquery only, no jquery works at all. If I use the Liferay copy of jquery, all of their scripts work, but none of mine. If both jquery files are linked, all of my stuff works, but not theirs. If I replace the jquery.js with the newest version, none of the jquery works.

I am at my wits' end trying to figure this out. I am not trying to do anything overly sophisticated, and assumed that I should be able to use the jquery library that's already linked. The fact that my scripts only work when both jquery.js files are linked completely baffles me.

Does anyone have any ideas at all? I am losing my mind!
Dikie Rendra Aditya
RE: Issues with jQuery conflicts, functions not working, etc.
August 25, 2009 8:53 PM
Answer

Dikie Rendra Aditya

Rank: New Member

Posts: 8

Join Date: March 11, 2009

Recent Posts

Hi there... I'm currenly also have problem with jQuery, my portlet is using jQuery 1.3.2 version and I've manage to resolve this issue by using this script:

1
2var dom = {};
3dom.query = jQuery.noConflict(true);


for example.. if I want to use jQuery date picker then I just use this:
1
2dom.query(document).ready(function(){
3    dom.query('#receivedDate').datepicker({
4        dateFormat: 'dd-mm-yy',
5        changeMonth: true,
6        changeYear: true
7        });
8});


Hope this helps
Vytautas R
RE: Issues with jQuery conflicts, functions not working, etc.
January 13, 2010 7:27 AM
Answer

Vytautas R

Rank: New Member

Posts: 12

Join Date: December 8, 2009

Recent Posts

Dikie Rendra Aditya:
Hi there... I'm currenly also have problem with jQuery, my portlet is using jQuery 1.3.2 version and I've manage to resolve this issue by using this script:

1
2var dom = {};
3dom.query = jQuery.noConflict(true);


for example.. if I want to use jQuery date picker then I just use this:
1
2dom.query(document).ready(function(){
3    dom.query('#receivedDate').datepicker({
4        dateFormat: 'dd-mm-yy',
5        changeMonth: true,
6        changeYear: true
7        });
8});


Hope this helps



Hi, Dikie.

I didn't manage to achieve jquery 1.3.2 working in parrallel with bundled 1.2.6..

where do you place this call?
1
2var dom = {};
3dom.query = jQuery.noConflict(true);

above or below referencing your copy of jQuery 1.3.2 ?

After all, how do you access each version of jquery?
I suppose "dom.query" should execute newer 1.3.2 version of JS, right?

Thanks!
Thomas Berg
RE: Issues with jQuery conflicts, functions not working, etc.
January 14, 2010 2:52 AM
Answer

Thomas Berg

Rank: Regular Member

Posts: 121

Join Date: September 7, 2009

Recent Posts

How are you referring to the jQuery library in your functions?

I use the bundled (1.2.6) jQuery library and i'm able to use jQuery by skipping the $ character and instead writing jQuery

For example

1jQuery(document).ready(function() {
2    jQuery("#some-element").click(function() ...
3
4function ordinaryJSFuntionWithjQuery {
5    jQuery("#some-element").keyup(function(event) { ...
6   


If you want to use the $ inside of your functions, you can write them like this:

1jQuery(document).ready(function([b]$[/b]) {
2    [b]$[/b]("#some-element").click(function() ...


You should also be able to replace 1.2.6 with the newest version.
Just overwrite (as you already have) the jquery.js file in the folder
webapps\ROOT\html\js\jquery (i'm using tomcat).

I have tested this without problems but reverted as I wanted to keep the bundle free from changes.


HTH

/ Thomas
Vytautas R
RE: Issues with jQuery conflicts, functions not working, etc.
January 20, 2010 1:52 AM
Answer

Vytautas R

Rank: New Member

Posts: 12

Join Date: December 8, 2009

Recent Posts

Hi, Thomas,

Thanks for the replay.


Thomas Berg:
How are you referring to the jQuery library in your functions?

I use the bundled (1.2.6) jQuery library and i'm able to use jQuery by skipping the $ character and instead writing jQuery


I'm using jQuery keyword for accessing the library.


Thomas Berg:
You should also be able to replace 1.2.6 with the newest version.
Just overwrite (as you already have) the jquery.js file in the folder
webapps\ROOT\html\js\jquery (i'm using tomcat).

I have tested this without problems but reverted as I wanted to keep the bundle free from changes.



Is it possible to renew jQuery version used in Liferay by rewriting files without breaking Liferay code? As I know, jQuery 1.3.2 is not backwards compatible (accessing elements attributes, etc). So, removing v1.2.6 is not an option. Or is it?

What I want to do is leave version 1.2.6 for Liferay functionality and myself work with new 1.3.2 version of jQuery. And the question is how to make different versions not to compete with each other?
Thomas Berg
RE: Issues with jQuery conflicts, functions not working, etc.
January 21, 2010 2:19 AM
Answer

Thomas Berg

Rank: Regular Member

Posts: 121

Join Date: September 7, 2009

Recent Posts

Hi Vytautas,

I might have been somewhat careless saying that it's allright to simply replace the current jQuery library that is shipped with Liferay. I didn't have any problems but didn't test things enough to make such a general claim.

You may want to check this discussion for some more information on how to run different versions of jQuery within the same page.

if you are including jQuery 1.4 (or any other version) for a single portlet for example, by using <footer-portlet-javascript> inside of liferay-portlet.xml, you could perhaps edit the jQuery-1.4 - file and append

1jq14 = jQuery.noConflict(true);

at the end of the file. You would then be able to use the new library in your portlet by referencing the new jQuery library with like this:

1jq14(document).ready(function(){ ...


I haven't tested this but it should (?) work.

HTH
Anonymous
RE: Issues with jQuery conflicts, functions not working, etc.
January 21, 2010 1:58 PM
Answer

Anonymous

Hey Anna,

Are you building a custom theme? If you are, you can place the "ui.slider.js" in the javascript folder and it should load into Liferay from the theme level.

Check out the folder structure of a theme on this page: http://www.liferay.com/community/wiki/-/wiki/Main/Themes
Vytautas R
RE: Issues with jQuery conflicts, functions not working, etc.
February 3, 2010 12:03 AM
Answer

Vytautas R

Rank: New Member

Posts: 12

Join Date: December 8, 2009

Recent Posts

Hi, Thomas.

Thanks for the help.

I'm currently working on other things, but in a few days i will try what i learned from your post. Thanks!


Thomas Berg:
Hi Vytautas,

I might have been somewhat careless saying that it's allright to simply replace the current jQuery library that is shipped with Liferay. I didn't have any problems but didn't test things enough to make such a general claim.

You may want to check this discussion for some more information on how to run different versions of jQuery within the same page.

if you are including jQuery 1.4 (or any other version) for a single portlet for example, by using <footer-portlet-javascript> inside of liferay-portlet.xml, you could perhaps edit the jQuery-1.4 - file and append

1jq14 = jQuery.noConflict(true);

at the end of the file. You would then be able to use the new library in your portlet by referencing the new jQuery library with like this:

1jq14(document).ready(function(){ ...


I haven't tested this but it should (?) work.

HTH
Path Finder LifeRay
RE: Issues with jQuery conflicts, functions not working, etc.
April 17, 2010 5:14 AM
Answer

Path Finder LifeRay

Rank: Expert

Posts: 262

Join Date: September 18, 2009

Recent Posts

hi anna,
i am just visiting jquery stuff and pass through your query. I am also using jquery in my project. R you using jquery in ext environment. where you find the jquery folder in liferay.

i am workin on plugins, and badly needed some working examples of jquery viz.,accordion, dialoges etc.,

it's already 1 year on for your query i guess. so you might have got the answer, if yes send me the reply,


thanking you,
Anu malik
RE: Issues with jQuery conflicts, functions not working, etc.
February 6, 2014 4:27 AM
Answer

Anu malik

Rank: New Member

Posts: 17

Join Date: December 5, 2013

Recent Posts

Hi, using jquery in view.jsp in portlet . Its not working and not getting any error . so I put jquery in js folder of portlet . Now it is giving error " TypeError: $(...) is null " in mozilla
browser . After a lot of efforts putting into this . find reason of problem .
it is error of $ sign which we are using in jquery .so change this and problem solved .

var $j = jQuery.noConflict();
$j(document).ready(function() {
});

Put code inside this block now and it will work . It took me a lot of time because i didn't find out why my js is not working , is this error of jquery . is this error of jquery compatibility . is my js conflicting with other javascript . But finally i found my solution .

Regards,
Anu
Suresh Kumar Dasari
RE: Issues with jQuery conflicts, functions not working, etc.
October 20, 2014 4:56 PM
Answer

Suresh Kumar Dasari

Rank: New Member

Posts: 4

Join Date: December 2, 2010

Recent Posts

Anu malik:
Hi, using jquery in view.jsp in portlet . Its not working and not getting any error . so I put jquery in js folder of portlet . Now it is giving error " TypeError: $(...) is null " in mozilla
browser . After a lot of efforts putting into this . find reason of problem .
it is error of $ sign which we are using in jquery .so change this and problem solved .

var $j = jQuery.noConflict();
$j(document).ready(function() {
});

Put code inside this block now and it will work . It took me a lot of time because i didn't find out why my js is not working , is this error of jquery . is this error of jquery compatibility . is my js conflicting with other javascript . But finally i found my solution .

Regards,
Anu



This works but the existing jquery related components are not working. do you also face the same issue?