Trigger Javascript when changing filters

Most of the times a button or some kind of interaction from the user needs to be done in order to trigger javascript functions after marking or filtering out data. With this timer approach, we no longer need that!




html:

<b>Simple Javascript Widget:</b>
<div style='width:80%'><div id='myWidget'></div></div>
<hr/>
<b>(Hidden) Calculated Value passed to widget:</b>
<span id='myCV'>
   <SpotfireControl id="6f842c14..." />

</span>

Javascript:

//this function gets the value from a Calculated Value
var oldValue=0
function updateValue() {
 
//get value from a Label Property Control or from a Calculated Value
newValue=$("#myCV").text()

//update widget (only when the value changes)
if(oldValue!=newValue){

$('#myWidget').css({
background:'gray'
,color:"navy"
,textAlign:"center"
,margin:"10px"
,padding:"5px"
,borderStyle:"outset"
,width:oldValue+"%"
}).text(newValue).animate({width:newValue+"%"},250)
}

oldValue=newValue

}

//run once
updateValue()

//run constantly

setInterval(updateValue,500)


Previous
Next Post »