Foren
problems with autocomplete jquery
Valeria P, geändert vor 12 Jahren.
problems with autocomplete jquery
New Member Beiträge: 3 Beitrittsdatum: 08.08.11 Neueste Beiträge
hello all,
I'm trying to develop the functionality "autocomplete" in my search page.
the page view.jsp of my portlet is very simple and is the following:
but it doesn't work.
What is wrong?
Can you help me?
Thank you
Valeria
I'm trying to develop the functionality "autocomplete" in my search page.
the page view.jsp of my portlet is very simple and is the following:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%-- Uncomment below lines to add portlet taglibs to jsp
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<portlet:defineobjects />
<%PortletPreferences prefs = renderRequest.getPreferences();%>
--%>
<script src="/html/js/jquery/jquery.js" type="text/javascript"></script>
<script src="/html/js/jquery/ui.core.js" type="text/javascript"></script>
<script src="/html/js/jquery/ui.widget.js" type="text/javascript"></script>
<script src="/html/js/jquery/ui.position.js" type="text/javascript"></script>
<script src="/html/js/jquery/ui.autocomplete.js" type="text/javascript"></script>
<script>
jQuery(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
jQuery( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
<input id="tags" name="tags">
but it doesn't work.
What is wrong?
Can you help me?
Thank you
Valeria
David H Nebinger, geändert vor 12 Jahren.
RE: problems with autocomplete jquery
Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
What is wrong is that you cannot just drop javascript onto a portlet page and expect it to work.
Javascript includes should be covered in liferay-portlet.xml and not be part of the body content.
Javascript includes should be covered in liferay-portlet.xml and not be part of the body content.
Valeria P, geändert vor 12 Jahren.
RE: problems with autocomplete jquery
New Member Beiträge: 3 Beitrittsdatum: 08.08.11 Neueste Beiträge
thank you for your reply,
I tried to cover javascript includes in liferay-portlet.xml:
but there is an error when I deploy the portlet.
What can I do?
Thanks
I tried to cover javascript includes in liferay-portlet.xml:
<!--?xml version="1.0" encoding="UTF-8"?-->
<liferay-portlet-app>
<portlet>
<portlet-name>PortletProva</portlet-name>
<header-portlet-javascript>/html/js/jquery/jquery.js</header-portlet-javascript>
<header-portlet-javascript>/html/js/jquery/jquery.ui.core.js</header-portlet-javascript>
<header-portlet-javascript>/html/js/jquery/jquery.ui.widget.js</header-portlet-javascript>
<header-portlet-javascript>/html/js/jquery/jquery.ui.position.js</header-portlet-javascript>
<header-portlet-javascript>/html/js/jquery/jquery.ui.autocomplete.js</header-portlet-javascript>
<instanceable>true</instanceable>
</portlet>
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>
</role-mapper>
<role-mapper>
<role-name>guest</role-name>
<role-link>Guest</role-link>
</role-mapper>
<role-mapper>
<role-name>power-user</role-name>
<role-link>Power User</role-link>
</role-mapper>
<role-mapper>
<role-name>user</role-name>
<role-link>User</role-link>
</role-mapper>
</liferay-portlet-app>
but there is an error when I deploy the portlet.
What can I do?
Thanks
David H Nebinger, geändert vor 12 Jahren.
RE: problems with autocomplete jquery
Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
What is the error?
André Bunse, geändert vor 12 Jahren.
RE: problems with autocomplete jquery
Junior Member Beiträge: 85 Beitrittsdatum: 16.03.12 Neueste BeiträgeValeria P:
<portlet-name>PortletProva</portlet-name>
<header-portlet-javascript>/html/js/jquery/jquery.js</header-portlet-javascript>
This way you try to load your scripts under root path of the portlet e.g.
/PortletProva-portlet/html/js/jquery
for using "/html/js/" in "webapps/ROOT/" you must use
<header-portlet-javascript>[b]/..[/b]/html/js/jquery/jquery.js</header-portlet-javascript>
or when javascript is in your portlet js
<header-portlet-javascript>[b]/js/jquery/jquery.js[/b]</header-portlet-javascript>
HTH
André