Navigation bar which has links that navigate to some other iframes

(Saurabh Kapoor) #1
</script>
<div class='nav'>
<ul>
{% for li in th_coun_li %}
<li><a href="#" onclick=Myfunction({{li}})>Thread Dump {{li}}</a></li><br> 
{% endfor %}
</ul>

</div></div><div id="frame"></div>

<script>
function Myfunction(li){
src1="<iframe src='{% url 'threadcount1' li %}' width='2000' height='1000';> 
</iframe>";
document.getElementById('frame').innerHTML = src1 ;
}

I am trying to make a nav bar when that nav bar links are clicked then it will open an i frame but it is giving me this error Reverse for ‘threadcount1’ with arguments ‘(’’,)’ not found. 1 pattern(s) tried: [‘mainpage/analysis/threadcount/(?P

[0-9]+)$’]
0 Likes

(Basil Jose) #2

what is in th_coun_li, li must be an integer or li.id may work if it is a model object.
here it looks like the value of li is an empty string (’’) in some case. so it won’t match with the url pattern, since your url is expecting to receive an integer

0 Likes

(Saurabh Kapoor) #3

it is just a list of integers

0 Likes

(Saurabh Kapoor) #4

tha value of li is an integer

0 Likes

(Basil Jose) #5

it won’t work as you expected, since DTL will render first since it is from server side. in the script li will not have any value.

1 Like

(Saurabh Kapoor) #6

is there any way i can make this work ?

0 Likes

(Basil Jose) #7
</script>
  <div class='nav'>
  <ul>
  {% for li in th_coun_li %}
  <li><a href="#" onclick=Myfunction('{% url 'threadcount1' li %}')>Thread Dump {{li}}</a></li><br> 
  {% endfor %}
  </ul>

</div></div><div id="frame"></div>

<script>
  function Myfunction(url){
  src1="<iframe src="+url+" width='2000' height='1000';> 
  </iframe>";
  document.getElementById('frame').innerHTML = src1 ;
}

Try this will work :slight_smile:

1 Like