Hulk
Hulk

Reputation: 34200

Comparison of js andtemplate tags

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

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

Upvotes: 3

Views: 2350

Answers (1)

gruszczy
gruszczy

Reputation: 42228

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

Upvotes: 3

Related Questions