0

I have an html site consisting of many "cards", each card being a template and each card containing a list with an id tag.

Since the form IDs have to be unique I can not just name them with a hardcoded string but have to incorporate some card specific identifier.

I tried the following

    <ul id= "tags"{{ object.id }}>
        <li>Tag2</li>
    </ul>

which I then try to refer to in a java script using

 <script type="text/javascript">
    $(function () {
        $("#tags"{{ object.title }}).tagit({
           ...
        });
    });
</script>

But unfortunately this does not seam to work. Does anybody know how to mix strings and template variables in such a situation correctly?

2
  • What is the error you are getting? have you tired just id="tags{{ object.id }}"? Commented Jul 10, 2013 at 13:51
  • you need: <ul id="tags{{ object.id }}">. Now you are getting <ul id="tags"1> in the output Commented Jul 10, 2013 at 13:53

1 Answer 1

4

You need to place the template code inside the quotation marks.

<ul id="tags{{ object.id }}">
    <li>Tag2</li>
</ul>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.