Wednesday, November 2, 2011

Problems with jquery and accessing django template system

I have a url that I need to attach to link that is in a jquery
section. It seem like the django template system is not getting the
variable. For example:

$.each(event,function(index,value){
var url = "{% url fiesta.views.detail "+
event[index].pk +" %}"

$('#event_results').append(
'<a href=" '+ url +' "><b>' + event[index].fields.title +
'</b></a><br />' + event[index].fields.description + '<br />'
)

});

},

"json"
);

------------------------------PROBLEM----------------------------
I need this url to be formatted like: {% url fiesta.view.detail 1 %}
Where the number 1 would replace the event[index].pk
However, it keeps printing the text: "event[index].pk" instead of the
value. I have checked that the variable is returning values and it is
returning values outside of django template blocks.

I don't know, but it seems that the django template is reading the
data before it is evaluated by jquery/javascript.

How can I format the django template so that i can evaluate jquery variables.

Thanks.

regard,
Kevin

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