Cannot insert Terms of Service using jQuery
- 6 years ago
Hi PAULEM ,
I would suspect that the resulting JavaScript is not well-formed. Let's say your terms of service is:
<a href="https://www.khoros.com">Click here to learn more</a>
When this gets rendered, your resulting JavaScript would be:
$('.tos').html(<a href="https://www.khoros.com">Click here to learn more</a>);
which is not valid JavaScript.
Instead you might try something like this:
$('.tos').html('${text.format('page.user_signup.terms_of_service')?js_string}');
The ?js_string is a Freemarker built-in to convert a string to be suitable for output into JavaScript strings. And the surrounding single quotes will allow your JavaScript to treat the rendered TOS as a string.
End the end, this would render to something like:
$('.tos').html('<a href=\"https://www.khoros.com\">Click here to learn more</a>');
Which should give you a better result.
That said, inserting content via DOM manipulation is a practice we typically advise against. This is the "Help"/"FAQ" pages you're talking about, as in /t5/help/faqpage? The sections of the FAQ should be editable via Studio. So I'd be curious to know more about the issue you're encountering. There may be a better way to approach this.