Skip to main content

Hi all,
I’m looking for a way to inject template text with merge fields dynamically to my page (at runtime, with JS).

Example:
I want to add a text like “… the latest status is  {{status__c}} …”  and have the merge field transformed to status value.

My idea was to use a template field, set it’s new text and render it again.
I replaced the fields text in the HTML DOM element with JS (which works). But after calling the render() method of the template field,  the old/previous content is set again.

Any suggestions?

If you are trying to update the value to be somthing different than what is in the model - you will have to try something different.  The easiest way to go about this will be to change the value of the field in your model (status__c) and then re-render the template. 


If you are using the standard renderer in your javascript, you may have this:

  • skuid.ui.fieldRenderers[field.metadata.displaytype].read( field, value )
The javascript needs to change value before reaching the renderer statement.


Rob/Mike, thanks for your hints.
I found the merge API is what I was looking for (https://docs.skuid.com/latest/en/skuid/merge-syntax/)


var mergedHtml = skuid.utils.merge( <br> 'row', <br> myHtmlTemplate, <br> {createFields:false}, <br> model, <br> row ).html();<br><br>

I think, my problem description was not clear enough.