Message Boards

jquery autocomplete usage

anantharam as, modified 15 Years ago.

jquery autocomplete usage

New Member Posts: 2 Join Date: 5/19/08 Recent Posts
we are trying to use autocomplete jquery ui component which is part of Liferay.

Following sample works fine as a simple web app
http://docs.jquery.com/Plugins/Autocomplete

where as if we try to use it as part of Liferay portlet its failing.
saying "autocomplete is not function.


Can anyone point us to right usage of autocomplete that work's with jquery in Liferay.
anantharam as, modified 15 Years ago.

RE: jquery autocomplete usage

New Member Posts: 2 Join Date: 5/19/08 Recent Posts
I got the solution now.

instead of $ we need to use jQuery for it to work in Liferay.
Robert Bohonek, modified 15 Years ago.

RE: jquery autocomplete usage

New Member Post: 1 Join Date: 2/26/09 Recent Posts
I got solution for liferay-portal-5.2.

First you must include javascript ui.autocomplete.js (<portal-root>\jboss-tomcat-4.2.3\server\default\deploy\ROOT.war\html\js) into liferay-portlet.xml (see Liferay wiki) as <header-portlet-javascript>.

Second you try this code in jsp :


<script type="text/javascript">
jQuery(document).ready(function(){
	var mydata =  [ "aaaa", "bbbb" , "cccc", "aabb" ];
	jQuery('#acbox').autocomplete({data:mydata});
	}
	);
</script>

Autocomplete : <input id="acbox" type="text">
thumbnail
Ryan McKeel, modified 14 Years ago.

RE: jquery autocomplete usage

Junior Member Posts: 27 Join Date: 7/14/08 Recent Posts
With Liferay v5.2.2, I find that this works. I put it in a web content (previously 'journal entry') display:

<script type="text/javascript" src="/html/js/jquery/ui.autocomplete.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
	var mydata = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");
	jQuery('#acbox').autocomplete({data:mydata});
});
</script>
<input id="acbox" type="text">


Doing mydata using split(" ") makes it easier to type in the data.
preethi babu, modified 14 Years ago.

RE: jquery autocomplete usage

New Member Posts: 4 Join Date: 9/23/09 Recent Posts
hi all,

how can we get multiple values using delimeters in the textBox.

this how i tried but its not working. only the first one come.After a comma others are not populated

<script type="text/javascript">
jQuery(document).ready(function(){
var mydata = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");
jQuery('#relIdeas').autocomplete({data:mydata,delimiter: /(,|;)\s*/}); }
);
</script>
John Bush, modified 14 Years ago.

RE: jquery autocomplete usage

New Member Posts: 2 Join Date: 10/12/09 Recent Posts
Why the need to specify {data:mydata} for this to work? The code base I am converting from does not require the 'data:' prefix and I can't find a reason even on the authors url. I am trying to understand it because I assume now there will be a few more gotchas having to migrate backwards from 1.3.2 to 1.2.6 that is in EE 5.2 SP3!
Latara Smith, modified 13 Years ago.

RE: jquery autocomplete usage

New Member Posts: 13 Join Date: 2/15/10 Recent Posts
Hi guys,

thanks a lot for your guidelines. Now I am trying to substitue mydata with remote content processed by my Portlet's processAction method.
Any tips on how to do that?

I know I have to add something along the lines of:


 var url = '<portlet:actionurl windowState="<%=LiferayWindowState.EXCLUSIVE.toString()%>" />'

jQuery('#acbox').autocomplete({

    	 source: function(request, response){
    	     jQuery.ajax(url: url, {keyword: keyword}, function(data){
					response(data);});
        	 }
   		}
     


Also I am not quite sure how the processAction method should return the autocomplete suggestions...

Any help would be greatly appreciated!

cheers,

L.
Javier Vera, modified 9 Years ago.

RE: jquery autocomplete usage

New Member Posts: 18 Join Date: 8/1/14 Recent Posts
yo guys Liferay is now in 6.2 version and a guy who i work with had disabled parameter names with requiered namespace... and this worked.
Anyone know how to fix this?? or at least let Liferay pass this library???