There are a couple of ways, but here's one off the top of my head:
Base template:
<script>
$(function(){
function1() { ... }
function2() { ... }
{% block additional_domready %}{% endblock %}
});
{% block additional_js }%}{% endblock %}
</script>
child template that extends base template:
{% block additional_domready %}
function3() { ... }
{% endblock %}
{% block additional_js %}
//js that runs outside of document.ready
{% endblock %}
-- dz
On Tue, Feb 16, 2010 at 2:46 PM, Joel Stransky <[email protected]> wrote:
> Still very new to django so excuse the newbish questions.
>
> This might be obvious but I need a smart solution.
>
> I have a template that runs a jquery function at document ready which
> defines a few other functions. I only need a couple of these functions in
> the template I'm extending, the other I need tacked on to specific children
> of the template.
>
> So I have:
>
> <script type="text/javascript">
> $(document).ready(function(){
> //function 1
> $("#my_id").click(function() { /* do stuff */ });
>
> //function 2
> $("a.someClass").click(function() { /* do stuff */ });
>
> //function 3
> $("#my_other_id").hover(function() { /* do stuff */ });
> });
> </script>
>
> But what I need is to able to insert function 3 (or others) in a child of my
> base template
> Ideally it would look like this:
>
> {% block jquery %}
> {{ block.super }}
> //function 3
> $("#my_other_id").hover(function() { /* do stuff */ });
> {% endblock jquery %}
>
> How do I achieve something to that effect?
>
> --
> --Joel Stransky
> stranskydesign.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.