Friday, October 28, 2011

Re: Help in adding jQuery to my pages

Hello, Leonardo

First, which django version are you using? I recommend using the contrib staticfiles app to handle your static files [1]. Once you get the hang of it, it will pay off.

Second, see that you aren't getting 404 errors in the js URL. Using the dev server, you can easily read through the status codes returned when loading a view. A different solution (sometimes quicker) is hitting Ctrl+U in firefox and clicking through the links in <HEAD> to see the kind of errors you're getting.

Finally, if none of that works you could try loading jQuery through the Google Libraries Api [2]. Good luck!


Cheers,
AT

[1] https://docs.djangoproject.com/en/dev/howto/static-files/#with-a-template-tag
[2] http://code.google.com/apis/libraries/devguide.html#jquery

On Fri, Oct 28, 2011 at 11:05 AM, Leonardo Giordani <giordani.leonardo@gmail.com> wrote:
Hi all,

I'm trying to add a bit of jQuery to a page in a Django site. It seems
that my jQuery scripts are simply not loaded, while JS scripts work
perfectly.
Evan Firebug does not see the jQuery file as loaded.

This is what I do in base.html

   <head>
       <link href="/static/base.less" rel="stylesheet/less" type="text/css">
       <script src="/static/less.js" type="text/javascript"></script>
       {% block javascript %}{% endblock %}

and in my page

{% block javascript %}
<script src="/static/jquery-1.6.4.js" type="text/javascript"></script>
<script src="/static/tabs.js" type="text/javascript"></script>
{% endblock %}

and my tabs.js is

$(document).ready(function() {
   $('li').addClass("active");
}

If I edit jquery-1.6.4.js and add something as alert(), this works
perfectly. Other JS scripts work like a charm.

Any suggestion?

Thank you

Leo

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment