When I did something like this:
$("#show").click(function(){
{% for p in collection %}
options.push({
'href' : '{{ p.id }}',
});
{% endfor %}
});
I can retrieve the value of Django template variable.
However, when I was trying to do on other part:
$('[name=test]').live('click', function() {
alert('{{ current_state }}');
var msg = '<div class="userName"> {{ current_user }} </div>';
alert('Message' + msg);
});
I can't retrieve the value of Django template variable from this.
What went wrong from here? I have had this problem sometimes retrieving Django template variable in javasript / jQuery.
EDIT
When I execute following lines on top of everything else, the whole javasript is not working. Any idea why?
$('body').data('current_user_id', {{ current_user_id }});
$('body').data('current_user', {{ current_user }});