JS noob here. I'm not sure if this if I'm doing this correctly but I'm trying to run a script "within" another script.
<script type="text/discourse-plugin" version="0.8">
api.decorateWidget('post:after', helper => {
let post = helper.getModel();
if (post.get('post_number') % 3 === 0) { // after every 3 posts
return helper.rawHtml(`
<div class="lead_static_wrapper"><p>Label</p>
<div class="proper-ad-unit">
<div id="pr-ad-nr_main_1">
propertag.cmd.push(function() { proper_display('nr_main_1'); });
</div>
</div>
</div>
`);
}
});
</script>
I need this part to run but it just shows as text when live, and doesn't seem to be running.
propertag.cmd.push(function() { proper_display('nr_main_1'); });
This doesn't seem to be the working:
<script type="text/discourse-plugin" version="0.8">
api.decorateWidget('post:after', helper => {
let post = helper.getModel();
if (post.get('post_number') % 3 === 0) { // after every 3 posts
return helper.rawHtml(`
<div class="lead_static_wrapper"><p>Label</p>
<div class="proper-ad-unit">
<div id="pr-ad-nr_main_1">
<script>propertag.cmd.push(function() { proper_display('nr_main_1'); });</script>
</div>
</div>
</div>
`);
}
});
</script>
Is there a way to edit the JS structure so this works? I'm trying to make this work for Discourse forums. Any help is appreciated! Thanks!
Use a backslash to escape the closing slash.
<script>propertag.cmd.push(function() { proper_display('nr_main_1'); });<\/script>