jquery - Is it possible to pass keyword arguments via Django's {% url %} template tag? Keyword agument value should be from the html tags -
i have template file , want use url tag in template file.
html tag <input type="text" id="test_id" value="12" />
the url
url(r'^check/(?p<code>[a-za-z\d]+)/(?p<test_value>[a-za-z\d]+)/$', 'test_code', name='test_code' ),
template file javascript code in it.
`var value1 = $('#test_id').val()`; `var value2 = $('#test_id').val()`; '{% url "test_code" code=value1 test_value=value2 %}'
you can see have use url tag , not able set value1 , value2 html tags values. there way can pass html tag values keyword arguments of url tag.
not in way. because template rendered before it's sent user. @ time of rendering, value of input not known yet. also, template rendering won't run javascript.
what assign url javascript on client side. similar did, have connect action. $(document).ready
if input filled, or $(value1).on('change')
if waiting user's interaction.
Comments
Post a Comment