1

Say I have jquery code like this:

html += '<div class="index">' + item.index + '</div>';

// many more similar html += statements

// load items
$('div').append(html);

This html is getting too unmanageable, so I'd like to move it to an external file. What's the best way to pass variables to the HTML as i load it? Do i just have to load it and then put jquery commands in the first JS file? That's what it seems like, but I'd rather use a more template-like method.

1 Answer 1

6

put HTML where it belongs, in the HTML file. then use a templating plugin on jQuery to expand it.

some template plugins:

Sign up to request clarification or add additional context in comments.

1 Comment

I have been looking for a client side replacement for the ASPx Repeater. Looks like you nailed it. Thanks so much. helpful++

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.