Sena Gbeckor-Kove 15 年之前 Hi, this all sounds very nice. I have a question however and I can't find much direct information about useing javascript in LiferayFirstly, how does one go about adding jQuery plugins in LIferay, I am trying this with v5.0.1. Do I just add the javacript in the theme directory or what?Secondly, why is it that if I try and import js directly in portal-normal.vm pages cease to render correctly. Any other pointers/gotchas you know I'm going to run into would be much appreciated.Thanks 请登录以投票。 以……回复 取消 Nate Cavanaugh Sena Gbeckor-Kove 15 年之前 Hi Sena,To include jQuery plugins, you would simply put them in the theme's javascript/ folder. To reference them, you can use our built in macro like so:#js("$javascript_folder/jquery_plugin_file.js")Secondly, I'm not sure why the theme wouldn't render correctly, unless the javascript is doing something odd, or there is some sort of error during the inclusion.Two questions for you:When you say "renders incorrectly" what exactly do you mean? Does the content show up, but just looks off, or does it not render at all, etc?Secondly, how are you trying to import this javascript? When you say directly, I'm not sure if you mean directly in the <head> of the document with a call to an external javascript file, or embedded somewhere in the body with the javascript inline.Either way, it shouldn't give you render issues, unless the html is invalid, or the Javascript is writing html to the document that's invalid.Thanks Sena, 请登录以投票。 以……回复 取消 Sena Gbeckor-Kove Nate Cavanaugh 15 年之前 Thanks Nate, I got it working eventually, I'm not sure eactly what was wrong as I had definitely tried the #js("$javascript_folder/jquery_plugin_file.js") type command earlier. Its possible that other changes I made tot he HTML my have been causing problems. Thanks for your response though.ThanksS 请登录以投票。 以……回复 取消
Nate Cavanaugh Sena Gbeckor-Kove 15 年之前 Hi Sena,To include jQuery plugins, you would simply put them in the theme's javascript/ folder. To reference them, you can use our built in macro like so:#js("$javascript_folder/jquery_plugin_file.js")Secondly, I'm not sure why the theme wouldn't render correctly, unless the javascript is doing something odd, or there is some sort of error during the inclusion.Two questions for you:When you say "renders incorrectly" what exactly do you mean? Does the content show up, but just looks off, or does it not render at all, etc?Secondly, how are you trying to import this javascript? When you say directly, I'm not sure if you mean directly in the <head> of the document with a call to an external javascript file, or embedded somewhere in the body with the javascript inline.Either way, it shouldn't give you render issues, unless the html is invalid, or the Javascript is writing html to the document that's invalid.Thanks Sena, 请登录以投票。 以……回复 取消 Sena Gbeckor-Kove Nate Cavanaugh 15 年之前 Thanks Nate, I got it working eventually, I'm not sure eactly what was wrong as I had definitely tried the #js("$javascript_folder/jquery_plugin_file.js") type command earlier. Its possible that other changes I made tot he HTML my have been causing problems. Thanks for your response though.ThanksS 请登录以投票。 以……回复 取消
Sena Gbeckor-Kove Nate Cavanaugh 15 年之前 Thanks Nate, I got it working eventually, I'm not sure eactly what was wrong as I had definitely tried the #js("$javascript_folder/jquery_plugin_file.js") type command earlier. Its possible that other changes I made tot he HTML my have been causing problems. Thanks for your response though.ThanksS 请登录以投票。 以……回复 取消
Jeff Goodwin 15 年之前 Hi Nate, Great work! I am in the process of implementing Liferay 4.3.4 and would like to see an example of how to utilize JQuery tabs within a Liferay CMS VM Template. Is this possible? I saw that the tabs plugin is delivered with version 4.3.4. Thanks 请登录以投票。 以……回复 取消 kuhajeyan gunaratnam Jeff Goodwin 15 年之前 Thanks Nate! 请登录以投票。 以……回复 取消
Manuel de la Peña 14 年之前 Hello Nate, i've read your article but i'm not sure about it could work in my scenario. I'm developing in EXT enviroment, with Struts Portlets.You're talking about this:<a href="http://liferay.com/test/?p_p_state=exclusive" id="linkTrigger">Click me to update our text</a>.Here's how we'd do it:var linkTrigger = jQuery('#linkTrigger');var updateDiv = jQuery('#portletBox');linkTrigger.click( function(event) { updateDiv.html('<div class="loading-animation"></div>').load(this.href); return false; });But, in my case, i 've an action:var linkTrigger = jQuery('#linkTrigger');var updateDiv = jQuery('#portletBox');linkTrigger.click( function(event) { updateDiv.html('<div class="loading-animation"></div>').load("ext/app/my_action"); return false; });But it doesn't work, always get error page.What i'm doing wrong?Many thanks! 请登录以投票。 以……回复 取消 Nate Cavanaugh Manuel de la Peña 14 年之前 Hi Manuel,I believe you need to simply create a portlet url for your action, which you could do from Javascript like so:var actionURL = Liferay.PortletURL.createActionURL();actionURL.setParameter('ext/app/my_action');Then you could easily do: updateDiv.html('<div class="loading-animation"></div>').load(actionURL.toString());But if you're trying to load the results into a div, you probably need to create a render URL. Here is some more information here on create portlet urls in Javascript: http://www.liferay.com/web/eduardo.lundgren/blog/-/blogs/1820035Thanks for the comment Manuel. 请登录以投票。 以……回复 取消 Manuel de la Peña Nate Cavanaugh 14 年之前 Hello Nate, many thanks for your quick answer.I'm trying it, but i cannot get success. I'm not reaching the StrutsAction defined for "ext/app/detail". The div shows the page from a call this jQuery event (current page for the portlet)Here is my jQuery call: jQuery("[id^=view_]").click( function () { var renderURL = Liferay.PortletURL.createRenderURL(); renderURL.setParameter("<portlet:namespace/>struts_action","/ext/app/detail"); renderURL.setParameter("iddetail", jQuery(this).attr("iddetail") ); alert( "renderURL: " + renderURL.toString() ); jQuery("#detailDiv").dialog({ modal: true, resizable: true, width: 500, height: 500 }); jQuery("#detailDiv").dialog('open'); jQuery("#detailDiv").load(renderURL.toString() ); } ); 请登录以投票。 以……回复 取消 Manuel de la Peña Manuel de la Peña 14 年之前 Hello, Nate, have you read my post?many thanks! 请登录以投票。 以……回复 取消 alex ace Manuel de la Peña 14 年之前 Was your above issue ever resolved? Also would like to know how to get the results from the action into your div using the ajax example you were mentioning. 请登录以投票。 以……回复 取消
Nate Cavanaugh Manuel de la Peña 14 年之前 Hi Manuel,I believe you need to simply create a portlet url for your action, which you could do from Javascript like so:var actionURL = Liferay.PortletURL.createActionURL();actionURL.setParameter('ext/app/my_action');Then you could easily do: updateDiv.html('<div class="loading-animation"></div>').load(actionURL.toString());But if you're trying to load the results into a div, you probably need to create a render URL. Here is some more information here on create portlet urls in Javascript: http://www.liferay.com/web/eduardo.lundgren/blog/-/blogs/1820035Thanks for the comment Manuel. 请登录以投票。 以……回复 取消 Manuel de la Peña Nate Cavanaugh 14 年之前 Hello Nate, many thanks for your quick answer.I'm trying it, but i cannot get success. I'm not reaching the StrutsAction defined for "ext/app/detail". The div shows the page from a call this jQuery event (current page for the portlet)Here is my jQuery call: jQuery("[id^=view_]").click( function () { var renderURL = Liferay.PortletURL.createRenderURL(); renderURL.setParameter("<portlet:namespace/>struts_action","/ext/app/detail"); renderURL.setParameter("iddetail", jQuery(this).attr("iddetail") ); alert( "renderURL: " + renderURL.toString() ); jQuery("#detailDiv").dialog({ modal: true, resizable: true, width: 500, height: 500 }); jQuery("#detailDiv").dialog('open'); jQuery("#detailDiv").load(renderURL.toString() ); } ); 请登录以投票。 以……回复 取消 Manuel de la Peña Manuel de la Peña 14 年之前 Hello, Nate, have you read my post?many thanks! 请登录以投票。 以……回复 取消 alex ace Manuel de la Peña 14 年之前 Was your above issue ever resolved? Also would like to know how to get the results from the action into your div using the ajax example you were mentioning. 请登录以投票。 以……回复 取消
Manuel de la Peña Nate Cavanaugh 14 年之前 Hello Nate, many thanks for your quick answer.I'm trying it, but i cannot get success. I'm not reaching the StrutsAction defined for "ext/app/detail". The div shows the page from a call this jQuery event (current page for the portlet)Here is my jQuery call: jQuery("[id^=view_]").click( function () { var renderURL = Liferay.PortletURL.createRenderURL(); renderURL.setParameter("<portlet:namespace/>struts_action","/ext/app/detail"); renderURL.setParameter("iddetail", jQuery(this).attr("iddetail") ); alert( "renderURL: " + renderURL.toString() ); jQuery("#detailDiv").dialog({ modal: true, resizable: true, width: 500, height: 500 }); jQuery("#detailDiv").dialog('open'); jQuery("#detailDiv").load(renderURL.toString() ); } ); 请登录以投票。 以……回复 取消 Manuel de la Peña Manuel de la Peña 14 年之前 Hello, Nate, have you read my post?many thanks! 请登录以投票。 以……回复 取消 alex ace Manuel de la Peña 14 年之前 Was your above issue ever resolved? Also would like to know how to get the results from the action into your div using the ajax example you were mentioning. 请登录以投票。 以……回复 取消
Manuel de la Peña Manuel de la Peña 14 年之前 Hello, Nate, have you read my post?many thanks! 请登录以投票。 以……回复 取消 alex ace Manuel de la Peña 14 年之前 Was your above issue ever resolved? Also would like to know how to get the results from the action into your div using the ajax example you were mentioning. 请登录以投票。 以……回复 取消
alex ace Manuel de la Peña 14 年之前 Was your above issue ever resolved? Also would like to know how to get the results from the action into your div using the ajax example you were mentioning. 请登录以投票。 以……回复 取消