Re: For loop problem in template..Is this correct

2011-08-16 Thread victorkendy
Hi The for tag iterates over the elements of the list you are using so your code should be $(function() { var data = []; var i = something(); {% for x in content %} data[i] = { roll_no: {{x.roll_no}},

Re: For loop problem in template..Is this correct

2011-08-15 Thread Konstantin Sushenko
I would just write a template tag that outputs the whole JS function. templates are too limiting in what you can use in {{}} brackets. konstantin On Aug 15, 8:38 pm, Landy Chapman wrote: > You may be right.  I am out of my element (pardon the pun). However, > assuming your "content" was this: >

Re: For loop problem in template..Is this correct

2011-08-15 Thread Landy Chapman
You may be right. I am out of my element (pardon the pun). However, assuming your "content" was this: content = [ { 'roll_no':1, 'cell_no': 1, 'nationality':'nation1'}, { 'roll_no':2, 'cell_no': 2, 'nationality':'nation2'}, { 'roll_no':3, 'cell_no': 3, 'nationality':'nation3'}, the django templ

Re: For loop problem in template..Is this correct

2011-08-15 Thread Adam Zedan
I dont think we could even use "[]" as in roll_no: {{content[0].roll_no}}, am i correct ?? couldnt find any reference to it on https://docs.djangoproject.com/en/dev/topics/templates/ On Tue, Aug 16, 2011 at 5:07 AM, Landy Chapman wrote: > @Konstantin Sushenko nice catch! > >> as a resul

Re: For loop problem in template..Is this correct

2011-08-15 Thread Landy Chapman
@Konstantin Sushenko nice catch! >> as a result of this you will have a series of 'data[i] = ...' >>assignments in your output. where 'i' would be undefined. So could he use this: JS isn't my thing, and this is approaching too_clever > $(function() { i = 0; >             var dat

Re: For loop problem in template..Is this correct

2011-08-15 Thread Adam Zedan
okay so i temporarily removed the loop just to see if the template works $(function() { var data = []; data[0] = { roll_no: {{content[0].roll_no}}, cell_no: {{content[0].cell_no}}, nationality:

Re: For loop problem in template..Is this correct

2011-08-15 Thread Landy Chapman
On Aug 15, 11:45 pm, Adam Zedan wrote: > Hi i am getting a problem with my for loop which i used in my template.Could > you kindly let me know what is going wrong in here. > The for loop is in a jquery function I think this: >                {% for x in range(len(content)) %} .. is not allowed

Re: For loop problem in template..Is this correct

2011-08-15 Thread Adam Zedan
Ooops.. sorry for the i: The code is $(function() { var data = []; {% for x in range(len(content)) %} data[x] = { roll_no: {{content[x].roll_no}}, cell_no: {{content[x].cell_no}},

Re: For loop problem in template..Is this correct

2011-08-15 Thread Konstantin Sushenko
hello, as a result of this you will have a series of 'data[i] = ...' assignments in your output. where 'i' would be undefined. konstantin On Aug 15, 7:45 pm, Adam Zedan wrote: > Hi i am getting a problem with my for loop which i used in my template.Could > you kindly let me know what is going w