With this approach you can have a checkbox that can trigger javascript and python scripts:
The calculated value click action toggles a Boolean document property. When this Boolean doc property changes it triggers the iron python script.
The javascript is triggered by adding a click event handler
Explanation
- Calculated value has a custom expression to show a checkbox character marked when document property is on or off:
If(${booleanDocProp},"☒","☐") - Calculated value has a script associated to run a python script when clicked. The script changes the state of the document property:
Document.Properties['booleanDocProp'] = not Document.Properties['booleanDocProp'] - Another python script changes the visualization title when document property changes:
//viz is a Visualization type script parameter
viz.Title = "Checkbox is ON" if Document.Properties['booleanDocProp'] else "Checkbox is OFF" - Optionally trigger a javascript when the calculated value changes.
cb=document.getElementById('boxyCheckbox')
cb.addEventListener('click',function(){
status = cb.innerText=="☒"?"OFF":"ON"
alert("Checkbox is " + status) })
2 comments:
This is awesome.... Very Clever!!!
thank you!!
Thanks BDoe!
Post a Comment