Comparison of js andtemplate tags

∥☆過路亽.° 提交于 2019-12-23 22:42:20

问题


<script>
function compare(profile_id)
{
{% ifequal '{{profile.id}}'  %}
  selected_sub='selected';
{% endifequal %}
}
</script>

How to compare {{profile.id}} and javascript variable profile_id


回答1:


function compare(profile_id){
    if (profile_id == {{ profilegroup.subject.id }})
        \\ do something
}

Keep in mind, that the script must be in a template, not in some served statically file with scripts (it must be filled with values, to work). Remember also, that you simply have templated script, that gets filled, when the response is generated and it will have exactly one value (for the profilegroup passed to the template).



来源:https://stackoverflow.com/questions/3546960/comparison-of-js-andtemplate-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!