0
votes

i am trying to use a specific Jquery menu mcdorpdown, the jequery its self was loaded but the local lib of mcdropdown won't, here is the error :

Erreur : $("#category").mcDropdown is not a function

the directory structure is :

  • src/main/webapp/jsp/common/headerCommercial.jsp (here i insert the javascript code)
  • src/main/webapp/javascript/ (here are the jquery libs including mcdropdown lib)

the source code of headerCommercial.jsp is the folowing :

<%@taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%><%@taglib
uri="http://java.sun.com/jsf/core" prefix="f"%><%@ page language="java"
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"                 "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script language="javascript"      src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script language="javascript"     src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"     type="text/javascript"></script>
<script language="javascript" src="javascript/jquery.mcdropdown.js"></script>
<script  language="javascript" src="javascript/jquery.mcdropdown.min.js"></script>
<script  language="javascript" src="javascript/jquery.bgiframe.js"></script>
<script type="text/javascript"> 
$(document).ready(function (){ 
$("#category").mcDropdown("#categorymenu"); 
$("#category").dblclick(function(){

});
}); 
</script>
<link type="text/css" href="css/jquery.mcdropdown.css" rel="stylesheet" media="all" />
<title>Insert title here</title>
</head>
<body>

...some code ...some code

3

3 Answers

0
votes

You could use the full path to call your script

src=http://yourdomainname.com/path/to/script.js

Or you could do src=../../javascript/script.js (each ../ takes you up one directory from the current directory.

0
votes

you can try

src="{request.contextPath}/javascript..."
0
votes

When it comes to Javascript I always use trh:script and this works perfectly for me, even in combination with jQuery and jQuery plugins. trh:script can be used to load external files using the source attribute, and inline Javascript using the text attribute.