Question & Answer
Question
How Can I Use Variable Values When Using Custom HTML In A Coach View?
Answer
Author: Jake Jepperson
Reviewer: Mike Zilbergleyt
You can use a variable value in a Custom HTML control in a Coach View by adding the variable as a Configuration Option in the Coach View and adding the below text in the Custom HTML control:
{{tw.options.variableName}}
If the variable is a complex variable, you may need to utilize a different design because {{tw.options.complexVariableName.variableName}} may not display the value on the page. You can, however, create an html element with a unique id and add the variable value as innerHTML to that element. For example, if you have a complex variable named user and that variable has attributes such as name, email and phone number, you can add the below html text in the Custom HTML control:
<span id="userName"></span>
And add the following javascript in the behavior tab of the Coach View in the View Event Handler:
var userName = this.context.element.querySelector("#userName");
userName.innerHTML = this.context.options.user.get("value").get("name");
Reviewer: Mike Zilbergleyt
You can use a variable value in a Custom HTML control in a Coach View by adding the variable as a Configuration Option in the Coach View and adding the below text in the Custom HTML control:
{{tw.options.variableName}}
If the variable is a complex variable, you may need to utilize a different design because {{tw.options.complexVariableName.variableName}} may not display the value on the page. You can, however, create an html element with a unique id and add the variable value as innerHTML to that element. For example, if you have a complex variable named user and that variable has attributes such as name, email and phone number, you can add the below html text in the Custom HTML control:
<span id="userName"></span>
And add the following javascript in the behavior tab of the Coach View in the View Event Handler:
var userName = this.context.element.querySelector("#userName");
userName.innerHTML = this.context.options.user.get("value").get("name");
[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSQTW3","label":"IBM On Demand Consulting for Hybrid Cloud"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"","label":""}}]
Was this topic helpful?
Document Information
More support for:
IBM On Demand Consulting for Hybrid Cloud
Software version:
All Versions
Document number:
778921
Modified date:
01 February 2019
UID
ibm10778921
Manage My Notification Subscriptions