留言板
problems with autocomplete jquery
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,修改在12 年前。
RE: problems with autocomplete jquery
Liferay Legend 帖子: 14918 加入日期: 06-9-2 最近的帖子
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.
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,修改在12 年前。
RE: problems with autocomplete jquery
Liferay Legend 帖子: 14918 加入日期: 06-9-2 最近的帖子
What is the error?
André Bunse,修改在12 年前。
RE: problems with autocomplete jquery
Junior Member 帖子: 85 加入日期: 12-3-16 最近的帖子Valeria 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é