freesniper
freesniper

Reputation: 79

troubles to run JQuery component with jsf project

i am trying to use some jquery component with jsf project, the error is :

Erreur : $ is not defined

here is the source code of my xhtm page :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">

<h:head>
<h:outputScript library="javascript" name=jquery-1.7.1.js target="body" />
<h:outputScript library="javascript" name="jquery.mcdropdown.js" target="body" />
<h:outputScript library="javascript" name="jquery.bgiframe.js" target="body" />
<h:outputStylesheet name="jquery.mcdropdown.css" library="css" />
<h:outputStylesheet name="style.css" library="css" />
<script type="text/javascript"> 
$(document).ready(function (){ 
$("#category").mcDropdown("#categorymenu"); 
$("#category").dblclick(function(){

});
}); 
</script>
</h:head>

<h:body>

<h1>JSF 2.0 and Resources example</h1>

<h:outputText styleClass="red-color"
    value="This is a Message (Red color)" />

<br />
<h:graphicImage library="images" name="sofa.png" />

<h:inputText id="category" value="" label="Menu"></h:inputText>

</h:body>

</html>

Blockquote

Upvotes: 0

Views: 512

Answers (1)

mrembisz
mrembisz

Reputation: 12880

JQuery library did not load properly. Could be you're missing quotes around its name in name="jquery-1.7.1.js". I am also not sure whether you can refer to $ in head while scripts have target body.

Upvotes: 1

Related Questions