python - Using Jinja2 for unqiue div ID's during loop? -


i can't seem figure out way around issue..

i have template takes inputs few different tables in database. tables contain x amount of info. in order show info onclick i'm using bit of javascript hide div contained in. however, div id={{ row.id }} gets populated during forloop in jinja. thought working @ first until realized {{ row.id }} can same different {{ row.id }} if coming different table.. exmaple;

{% row in packages %} # packages 1 of tables <div id="{{ row.id }}"> {{ row.price }} {{ row.date }} ..etc </div> <button onclick="togglediv("{{ row.id }}">show content</button>  other stuff in between...  {% entry in services %} # services 1 of tables <div id="{{ entry.id }}"> # possible entry.id + {{ loop.index }} ? i'm not positive make unique tho. {{ entry.price }} {{ entry.date }} ..etc </div> <button onclick="togglediv("{{ entry.id }}">show content</button> 

so issue running is possible row.id == entry.id because come different tables. trying figure out if maybe can use large list random unique numbers draw div id's from? i'm not sure how can jinja accomplish that? out of luck here? last major hurdle in template love figure out solution.. thoughts?

why don't prefix html ids table name ?

{% row in packages %} # packages 1 of tables <div id="package_{{ row.id }}"> {{ row.price }} {{ row.date }} ..etc </div> <button onclick="togglediv("package_{{ row.id }}")">show content</button>   {% entry in services %} # services 1 of tables <div id="service_{{ entry.id }}">  {{ entry.price }} {{ entry.date }} ..etc </div> <button onclick="togglediv("service_{{ entry.id }}")">show content</button> 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -