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

JQuery in mashup function (ThingWorx 9.1)

JakubJaskulski
Regular Member

JQuery in mashup function (ThingWorx 9.1)

Does ThingWorx 9.1 allow using JQuery in expressions?

6 REPLIES 6

Re: JQuery in mashup function (ThingWorx 9.1)

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. 

Re: JQuery in mashup function (ThingWorx 9.1)

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.

Re: JQuery in mashup function (ThingWorx 9.1)

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.

Re: JQuery in mashup function (ThingWorx 9.1)

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,

Re: JQuery in mashup function (ThingWorx 9.1)

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.

 

Re: JQuery in mashup function (ThingWorx 9.1)

JJ, indeed, that is one of the issues of the shadow dom, the fact that a widget based on it it is no longer 100% customizable as the previous non-shadow dom widgets.

One of the main reasons the shadow dom was used is because it made sure that changes that one widget did via CSS classes no longer can reflect on other widgets - one of the issues of the older widgets.This is known as "style isolation"

Assuming you tried to use the ThingWorx Themes - which provide a global, across-widgets styling - and you did not find the necessary capabilities, if this severely impacts your workload, make sure that you:

1. Open a user request in the ThingWorx Ideas forum section detailing this request

2. Discuss this with your Customer Success Manager to understand the problem, its impact and to arrange a possible workaround - if possible.

Announcements

Check out the upcoming Expert Session: Understanding ThingWorx Navigate Licensing in Community "Customer Events" section.