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

When is the callback updateProperty triggered for a customized widget ?

SOLVED
Highlighted
Peridot

When is the callback updateProperty triggered for a customized widget ?

Hi , 

 

For a customized widget, sometimes the callback function updateProperty is triggered as my expected, but sometimes not.  

 

I found the following situations that updateProperty will NOT be triggered : 

  1. afterRender is empty
  2. Div doesn't has nested div/span inside it . for example,  <div class="widget-content widget-helloWorld"><div class="DisplayText"></div></div> works,  but <div class="widget-content widget-helloWorld DisplayText"></div> doesn't work
  3. call this.setProperty function in afterRender won't be helpful in the above cases

I'm really confused about the behavior of triggering updateProperty , could someone give me a detailed description for updateProperty ? 

 

=============afterRender====================

this.afterRender = function () {
   //this.setProperty("BarTitle", 'test');
   valueElem = this.jqElement.find(".DisplayText");
   valueElem.text(this.getProperty("BarTitle"));
};

 

Regards,

Sean

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: When is the callback updateProperty triggered for a customized widget ?

Hi @seanccc.

 

Here's what I found:

 

  • The updatePropery() method is called anytime a bound value for a widget property changes.
  • First, encode the updated property's value using the htmlEncode() method from the Encoder library.
  • Then, use thisWidget's setProperty() and getProperty() methods to update and access this new value.
    • This step is important as the getProperty() method will perform extra sanitization on the values being returned to the UI.

 

If you still have questions, please let us know.

 

Regards.

 

--Sharon

View solution in original post

1 REPLY 1
Highlighted

Re: When is the callback updateProperty triggered for a customized widget ?

Hi @seanccc.

 

Here's what I found:

 

  • The updatePropery() method is called anytime a bound value for a widget property changes.
  • First, encode the updated property's value using the htmlEncode() method from the Encoder library.
  • Then, use thisWidget's setProperty() and getProperty() methods to update and access this new value.
    • This step is important as the getProperty() method will perform extra sanitization on the values being returned to the UI.

 

If you still have questions, please let us know.

 

Regards.

 

--Sharon

View solution in original post

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!