Jump to content
We've recently updated our Privacy Statement, available here. ×

Assigning values to document properties with Javascript not working in Spotfire 10


Amal Shaji

Recommended Posts

In my spotfire dashboard, I have a javscript which assigns the value of acalculated field to a document property. The html part is as follows:

 

 

The javascript is:

var fun1 = function(){

var c1 = $('#NumberValue').text().trim()

$('#Number input').val(c1).blur()

}

setInterval(fun1,100)

This stopped working after the upgrade to Spotfire 10. Post the upgrade, the values are getting copied from the div NumberValue to the div Number, But the document property associated with the second div is not getting updated.

I tried the following work around also:

var fun1 = function(){

var c1 = $('#NumberValue').text().trim()

$('#Number input').show()

$('#Number input').focus()

$('#Number input').val(c1).blur()

$('#Number input').hide()

}

setInterval(fun1,100)

This script was assiging the value to document property, But the focus function was activating the element each time the javascript runs. Hence we were unable to type values in other input fields in the same tab.

We cannot use the Iron python method for assigning document properties as it needs to be triggered by R datafunction and our server has limitations to handle the load.

So any javascript solutions/work arounds will be appreciated.

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...

Hi,

I believe I have found a possible solution/work-around for the issue, entirely based on pure JavaScript (since TIBCO removed jQuery starting from Spotfire X). The solution is to force a simulated Enter Keystroke while focusing the input box to trigger updating the Document Property. (No data function and R needed)

HTML (SpotfireControl Element is an single line input-box for a Doc. Prop.):

JS (focus and blur might no longer be needed for this solution, but I'm still keeping them just in case):

const inputConfirmationEvent = new KeyboardEvent("keypress", {

keyCode: 13,

bubbles: true,

cancelable: false

});

 

var elem = document.querySelector("#container input");

elem.value = "stringValue";

elem.blur();

elem.focus();

 

document.querySelector("#container input").dispatchEvent(inputConfirmationEvent);Hope it helps someone.

Best,

Aaron

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...