比较js和template标签 [英] Comparison of js andtemplate tags

查看:96
本文介绍了比较js和template标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

如何比较 {{profile.id}} 和javascript变量 profile_id

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

推荐答案

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).

这篇关于比较js和template标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆