Friday, October 28, 2011

Re: Help in adding jQuery to my pages

Oh, that's right! Too often I miss the closing );, especially when *reading* code.

It's very unfortunate javascript didn't have someone like Guido van Rossum as BDFL. Life for web developers would surely be easier if it too were developed with "be as readable as English" as a goal.

Glad to know you got it sorted out.

Take care!

AT

On Fri, Oct 28, 2011 at 12:13 PM, Leonardo Giordani <giordani.leonardo@gmail.com> wrote:
Sorry Andy and thank for your patience,

as I though the problem is simply simply bad JQuery.

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

what about some ");" to close statements?

Thanks

2011/10/28 Andre Terra <andreterra@gmail.com>:
> I'm sorry if I'm not understanding you, but regarding 2 and 3, if jQuery
> isn't being loaded, shouldn't you be getting a 404 error for the
> jquery-1.6.4.js file?
>
>
> Cheers,
> AT
>
> On Fri, Oct 28, 2011 at 11:30 AM, Leonardo Giordani
> <giordani.leonardo@gmail.com> wrote:
>>
>> Hi, thank you for your detailed answer.
>>
>> 1. I'm on Django 1.3 (1.3.0-final). I'll take a look at staticfiles
>> for sure, thanks.
>> 2. I'm getting no errors at all, other JS files in that directory load
>> perfectly. Firefox can reach them in source view.
>> 3. I'll try it, but it seems to me strange not being able to load and
>> use jQuery as other JS scripts.
>>
>> Is that jQuery file of mine (tabs.js) wrong? Is there some stupid
>> error I cannot spot?
>>
>> No one is experiencing the problem?
>>
>> 2011/10/28 Andre Terra <andreterra@gmail.com>:
>> > 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.
>> >
>>
>> --
>> 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.
>

--
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