[Grok-dev] Has Anyone Used DOJO or JQUERY with GROK?

Christian Klinger cklinger at novareto.de
Wed Feb 25 13:45:13 EST 2009


trex schrieb:
> Has anyone gotten GROK and Javascript libraries like DOJO or JQUERY to play
> together?
> 
> 

Hi,

this is not hard.

I try to give you a short demo.
-------------------------------

1. create a view in your app.py

class Example(grok.View):
     pass

2. copy the jquery.js in the static directory

3. create a my.js script in the static directory
    which holds your jquery code.
    Something like this:

$(document).ready(function(){
     $("h1#click").click(function(){
         $(this).next().slideToggle('slow');
     });
});



4. create a tempalte app_templates/example.pt

<html>
<head>
   <script type="text/javascript" src="" tal:attributes="src 
static/jquery.js">  </script>
   <script type="text/javascript" src="" tal:attributes="src 
static/my.js">  </script>
</head>
<body>

<h1 id="click"> Click me </h1>
<div> Go Away </div>

</body>
</html>



Now point your browser to http://localhost:8080/myApp/example

This is all untested :))
If you have further questions pleas ask...

HTH Christian



More information about the Grok-dev mailing list