Fórum

Issues with jQuery conflicts, functions not working, etc.

Anna Spargo-Ryan, modificado 14 Anos atrás.

Issues with jQuery conflicts, functions not working, etc.

New Member Mensagem: 1 Data de Entrada: 02/02/09 Postagens Recentes
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!
thumbnail
Dikie Rendra Aditya, modificado 14 Anos atrás.

RE: Issues with jQuery conflicts, functions not working, etc.

New Member Postagens: 14 Data de Entrada: 11/03/09 Postagens Recentes
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:


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


for example.. if I want to use jQuery date picker then I just use this:

dom.query(document).ready(function(){
    dom.query('#receivedDate').datepicker({
        dateFormat: 'dd-mm-yy',
        changeMonth: true,
        changeYear: true
        });
});


Hope this helps
Vytautas R, modificado 14 Anos atrás.

RE: Issues with jQuery conflicts, functions not working, etc.

New Member Postagens: 12 Data de Entrada: 08/12/09 Postagens Recentes
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:


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


for example.. if I want to use jQuery date picker then I just use this:

dom.query(document).ready(function(){
    dom.query('#receivedDate').datepicker({
        dateFormat: 'dd-mm-yy',
        changeMonth: true,
        changeYear: true
        });
});


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?

var dom = {};
dom.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!
thumbnail
Thomas Berg, modificado 14 Anos atrás.

RE: Issues with jQuery conflicts, functions not working, etc.

Regular Member Postagens: 131 Data de Entrada: 07/09/09 Postagens Recentes
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

jQuery(document).ready(function() {
    jQuery("#some-element").click(function() ...

function ordinaryJSFuntionWithjQuery {
    jQuery("#some-element").keyup(function(event) { ...
    


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

jQuery(document).ready(function([b]$[/b]) {
    [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, modificado 14 Anos atrás.

RE: Issues with jQuery conflicts, functions not working, etc.

New Member Postagens: 12 Data de Entrada: 08/12/09 Postagens Recentes
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?
thumbnail
Thomas Berg, modificado 14 Anos atrás.

RE: Issues with jQuery conflicts, functions not working, etc.

Regular Member Postagens: 131 Data de Entrada: 07/09/09 Postagens Recentes
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

jq14 = 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:

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


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

HTH
Vytautas R, modificado 14 Anos atrás.

RE: Issues with jQuery conflicts, functions not working, etc.

New Member Postagens: 12 Data de Entrada: 08/12/09 Postagens Recentes
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

jq14 = 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:

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


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

HTH
thumbnail
path finder liferay, modificado 13 Anos atrás.

RE: Issues with jQuery conflicts, functions not working, etc.

Expert Postagens: 262 Data de Entrada: 18/09/09 Postagens Recentes
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, modificado 10 Anos atrás.

RE: Issues with jQuery conflicts, functions not working, etc.

New Member Postagens: 18 Data de Entrada: 05/12/13 Postagens Recentes
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, modificado 9 Anos atrás.

RE: Issues with jQuery conflicts, functions not working, etc.

New Member Postagens: 4 Data de Entrada: 02/12/10 Postagens Recentes
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?