javascript - jquery toggle in a for loop using Jinga2 template -
i trying hide/show div within loop using jquery's toggle. when click button toggle, div slides out quick moment, hides again. when happens, toggle button seems disabled next click...then works again same problematic div display. used {{email.sender}} template value because when clicked on toggle button, items in list activated instead of one. below code inserted tab jquery (this part working). advice can give on this-
<div id="email_received_list"> {% email in email_received_list %} <p> <input type="button" id="{{email.sender}}" value="show message"> {{email.sender}}: {{ email.subject }} </p> <script> $(document).ready(function(){ $('#{{email.sender}}').click(function() { $('.{{email.sender}}').slidetoggle('fast'); return false; }); }); </script> <div class="{{email.sender}}" style="display:none; background-color:#4cf;width:100%;height:100%;"></div> {% else %} (you have not received messages yet.) {% endfor %}
ok, feel stupid on 1 - once added actual content div (not trying color square) worked fine. guess since in loop, trying size div match content. when there no content, div hid again. if know different on this, please let me know -thanks.
Comments
Post a Comment