cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

JQuery in mashup function (ThingWorx 9.1)

JakubJaskulski
5-Regular Member

JQuery in mashup function (ThingWorx 9.1)

Does ThingWorx 9.1 allow using JQuery in expressions?

5 REPLIES 5

I did a small test and validated that JQuery works in expression function in 9.1. Import the attached entity and view the mashup, on button click the expression function changes the URL. 

Thank you for your response. I tried to find definite answer somewhere in the documentation but I wasn't able to. I've tested your example and yes, it works fine.

 

My other question as a follow up is, can you use other functions such as selectors and css()? I this is my main goal with JQuery, and I was testing your example with simple background change:

 

 

$('#root_flexcontainer-2').css('background', 'rgb(0,0,0)');

 

 

In devtool it work, but when placed inside an expression it does not seem to do anything.

I am not sure what all functions we can use. I tried using 

$('#root_flexcontainer-2').css('background', 'rgb(0,0,0)');

but I was unable to make it work. If I find a way, I will update it here.

Hi @JakubJaskulski,

 

R&D strictly limited the functionality of jQuery over security concerns.  I unfortunately as well am not sure what is and is not allowed.

 

Instead of setting CSS using jQuery I would highly recommend using your expression widget to set the custom class property on the widget you are trying to modify.  This would ensure your solution is future safe and future developers would most likely look for custom css defined on the mashup not in an expression.

 

Thanks,

Of course I usually use custom classes, but jQuery was supposed to be a solution of an another issue. Because there are many shadow root in newer versions of widgets, custom css doesn't affect them. You can use ::part  if the element has this property, but it doesn't always have it. That's why I was looking for a different way to modify specific elements of a page.

 

Top Tags