Using the JS variable in the Django template tag

Source: Internet
Author: User

Django template tags are parsed on the server side and generated HTML data returned, how to apply the front-end JS variable to the template tag

It? There is really no good way to do this, you can only use one placeholder and then replace it in JavaScript. As shown below:

<script>...var uid = $ (this). attr (' uid '); var url = "{% url ' paas:ajx_get_viewlog_perm ' 12345%}"; url = url.replace (' 12345 ', uid);</script>


In the background URL is parsed into the actual string, the string contains 12345 of this substring, JS to get the value of the variable uid, and then the JS Replace function to replace the URL. Feel a bit awkward, but, run through, hehe!


This article is from the "Candle Shadow Red" blog, be sure to keep this source http://gccmx.blog.51cto.com/479381/1705564

Using the JS variable in the Django template tag

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.