Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Joel Kozikowski
jQuery usage examples?
February 15, 2008 1:49 PM
Answer

Joel Kozikowski

Rank: Expert

Posts: 405

Join Date: June 27, 2006

Recent Posts

Are there any current portlets and/or other code samples that use jQuery? I'm just now starting to use it (its pretty cool), but a lot of it is new to me.

Specifically, I'm looking for implementations that use the

 1Liferay.Portlet.ready(
 2
 3    /*
 4    This function gets loaded after each and every portlet on the page.
 5
 6    portletId: the current portlet's id
 7    jQueryObj: the jQuery wrapped object of the current portlet
 8    */
 9
10    function(portletId, jQueryObj) {
11    }
12);


but am also looking any/all usage examples as it pertains to Liferay.

Ideas?
Michael Young
RE: jQuery usage examples?
February 15, 2008 2:24 PM
Answer

Michael Young

LIFERAY STAFF

Rank: Liferay Master

Posts: 847

Join Date: August 4, 2004

Recent Posts

Not exactly what you're looking for, but here's an AOP example using jQuery:


http://www.liferay.com/web/ncavanaugh/home/blogs/hooking_into_liferay_s_javascript_functions
Joel Kozikowski
RE: jQuery usage examples?
February 16, 2008 9:17 AM
Answer

Joel Kozikowski

Rank: Expert

Posts: 405

Join Date: June 27, 2006

Recent Posts

Michael Young:
Not exactly what you're looking for, but here's an AOP example using jQuery:


http://www.liferay.com/web/ncavanaugh/home/blogs/hooking_into_liferay_s_javascript_functions


Great stuff! I'm going to start reading Nate's blogs on a regular basis. Very interesting stuff.

I must say once again I'm really impressed with the design of the new theme system that came along in 4.3. It makes dealing with browser quirks SO much easier, and it gives a LOT of flexibility. Kudos to Nate and anyone else involved in its architecture.

BTW - I found some good jQuery usage examples in the javascript.js file of the official liferay-jedi theme I downloaded from the official plug-ins page. It was close enough to what I was looking for to give me an example of typical jQuery usage.

If anyone else has any other examples, however, I'm still looking for tips! emoticon
Madhura Raut
RE: jQuery usage examples?
November 15, 2010 2:33 AM
Answer

Madhura Raut

Rank: Junior Member

Posts: 41

Join Date: November 11, 2010

Recent Posts

Hi,
I am new to portal and currently using Liferay 6.
I wanted to implement pop-up using jQuery. My code is working fine in JSF2. But its not working on liferay.Following is my code. Can you tell me why its not working. I am not getting any exceptions or errors. Please please help me.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:pcc="http://java.sun.com/jsf/composite/pcc"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:portlet="http://java.sun.com/portlet_2_0">

<h:head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>

<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.js "></script>

<script type='text/javascript' >

jQuery('#btnResult').click(function(){

var $element = $('#result'); // hidden div's ID
$element.dialog({
modal: true,
resizable:true,
draggable:true,
title:"Result",
close: function() {
},
buttons: {
ok : function() {
$element.dialog("close");
}
}
}).show();

});


});

</script>
</h:head>
<h:form>
<div id="result" style="display:none">
<h:outputLabel id="lblResult" value="#{adminToolSearchBean.result}"></h:outputLabel>
</div>
<h:commandButton id="btnResult" value="Open the dialog" />
</h:form>
</ui:composition>

I have tried writing the script in the form. But its not working
Dave Weitzel
RE: jQuery usage examples?
November 15, 2010 6:16 AM
Answer

Dave Weitzel

Rank: Regular Member

Posts: 203

Join Date: November 18, 2009

Recent Posts

One thing that may be causing the problem is if you have that comment in there.
I believe (I am reasonably new to Liferay as well) that they minify javascript during the jsp processing, single line comments with " //comment " will extend to the end. you need to use block comments " /* comment */ ".

Have you looked at the finished code on the page to check?
Tanweer .
RE: jQuery usage examples?
November 15, 2010 10:09 AM
Answer

Tanweer .

Rank: Expert

Posts: 319

Join Date: March 11, 2010

Recent Posts

Hi Madhura,

I think you can use the AUI pop , provided in LR6.

 1  <aui:script>
 2    Liferay.provide(window,'<portlet:namespace />callPopup',
 3    function(url1) {
 4    var A = AUI();
 5    var data = {};
 6    var dialog = new A.Dialog(
 7    {
 8    centered: true,
 9    destroyOnClose: true,
10    modal: true,
11    title: Liferay.Language.get('Display-Content'),
12    width: 600
13    }
14    ).render();
15    dialog.plug(
16    A.Plugin.IO,
17    {
18    data: data,
19    uri: url1
20    }
21    );
22    },
23    ['aui-dialog', 'aui-io']
24    );
25
26</aui:script>
Madhura Raut
RE: jQuery usage examples?
November 15, 2010 8:33 PM
Answer

Madhura Raut

Rank: Junior Member

Posts: 41

Join Date: November 11, 2010

Recent Posts

Hi Tanweer,

Can u tell me how to bind dynamic data. Coz I have to display the the information searched by the user in a tabular format.

Thank u emoticon
Madhura Raut
RE: jQuery usage examples?
November 15, 2010 8:34 PM
Answer

Madhura Raut

Rank: Junior Member

Posts: 41

Join Date: November 11, 2010

Recent Posts

Hi,
I have tried by removing all the comments but still its not working on the portal.emoticon
Apoorva Prakash
RE: jQuery usage examples?
November 15, 2010 8:45 PM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

 1<script type="text/javascript">
 2
 3    jQuery(document).ready(function() {
 4        jQuery("#addform").validate({
 5            rules:{
 6                empCode:{required: true,number:true},
 7                firstName:"required",
 8                mobile:{required: true,number:true},
 9                technology:"required",
10                email: {// compound rule
11                    required: false,
12                    email: true
13
14            },
15            }
16        });
17    });
18</script>


Hope this will help...

Thanks and Regards...
Madhura Raut
RE: jQuery usage examples?
November 16, 2010 5:29 AM
Answer

Madhura Raut

Rank: Junior Member

Posts: 41

Join Date: November 11, 2010

Recent Posts

Hi Apoorv,

Thanks for the help. But for some reason I need to know whts wrong with my code. Why its not working. Is it the logical mistake or something else. Please help me.
john paolo sagenes
RE: jQuery usage examples?
November 22, 2010 8:40 AM
Answer

john paolo sagenes

Rank: New Member

Posts: 1

Join Date: November 22, 2010

Recent Posts

Hi guys!! Are you a Jquery user? I just want to share something. I found a website that might help you on using jquery and here are some of the website's links:

http://www.jquery4u.com/basic-syntax/5-basic-jquery-syntax/
The link is about 5 Useful Basic jQuery Syntax like:
• Hide/Show
• Fade in/Fade out
• Stop
• Animate
• Slide Toggle

http://www.jquery4u.com/animation-and-effects/10-amazing-jquery-image-slider/
The link is about the 10 Amazing jQuery Image Slider

http://www.jquery4u.com/articles/benefits-jquery/
The link is about the benefits of using jquery

http://www.jquery4u.com/news/load-jquery-google-libraries-api/
The link is about Load jQuery with Google Libraries API

http://www.jquery4u.com/forms/5-awesome-jquery-drop-boxes/
The link is about the 5 Awesome JQuery Drop Down Boxes

So try visit it now and I hope this site helped you! emoticon
Dave Weitzel
RE: jQuery usage examples?
November 22, 2010 9:06 AM
Answer

Dave Weitzel

Rank: Regular Member

Posts: 203

Join Date: November 18, 2009

Recent Posts

Have you debugged it using alert() statements to ascertain how far the code gets?
What is displayed in your browsers debugging tools (firebug or chrome "inspect element")?
I suspect you just may need to wrap everything with a
$(document).ready(function(){
....
)}

block to initiate your jQuery objects?
Apoorva Prakash
RE: jQuery usage examples?
November 22, 2010 8:30 PM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

Hello Sagenes,
Useful infoarmation, thanks !!!
Madhura Raut
RE: jQuery usage examples?
November 22, 2010 9:22 PM
Answer

Madhura Raut

Rank: Junior Member

Posts: 41

Join Date: November 11, 2010

Recent Posts

Hey thank you so much. I have tried using alert boxes too. but its not entring the function which i have written. I will try using the block you have suggested and will let you know. thank u once again