0

This example does not work for me:

$.tmpl('<span class="ui-button ui-widget ui-icon-${data}">\
        ${data}</span>', \
        ["info", "delete"]\
)

since it will return nothing in place of ${data}. I also tried with ${item} which gave me same result.

What i want to achieve, is to insert the text "info" in the first generated span and "delete" in the next span.

As a workaround, i can pass in objects like so:

[{name: "info"}, {name: "delete"}]

and access them with ${name} directly.

But how to i make it work without the workaround?? What is the correct syntax for getting element in aray?

1 Answer 1

2

You forgot to add one $ sign before data. Change ${data} to ${$data}

Try this:

$.tmpl('<span class="ui-button ui-widget ui-icon-${$data}">${$data}</span>', ["info", "delete"])

Working example @ http://jsfiddle.net/ythSP/

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.