Trigger javascript from Dropdown-list property control (7.0+)

Trigger a javascript function after a dropdown property control changes. To trigger an ironPython, just associate a script on the document property.

<span id='dropDownDocProp'>
<SpotfireControl id="6d69ba781efa4b93ab8aaa1857a45d2d" />

MutationObserver = window.MutationObserver || window.WebKitMutationObserver;

//this is the target element to monitor changes
//just put the span id here. You can remove next line and add a script param called targetDomId
var targetDomId = "dropDownDocProp"

//function when dropdown value changes
var myFunction = function(oldValue,newValue){
alert("old value:["+oldValue+"]\nnew value:["+newValue+"]")
                //click on a actioncontrol with python script

//no need to change after this line.
var target = document.getElementById(targetDomId)

//callback is the function to trigger when target changes
var oldVal = target.innerText.trim()
var callback = function(mutations) {
newVal=$('#'+targetDomId+' .ComboBoxTextDivContainer').text()
if(newVal!=oldVal) myFunction(oldVal,newVal)
oldVal = newVal;

//this is to glue these two together
var observer = new MutationObserver(callback);

var opts = {
    childList: true, 
    attributes: true, 
    characterData: true, 
    subtree: true


Note: To trigger ironPython script, just associate the script with the document property

No comments: