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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

When is the callback updateProperty triggered for a customized widget ?

seanccc
17-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

 

ACCEPTED SOLUTION

Accepted Solutions
slangley
23-Emerald II
(To:seanccc)

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
slangley
23-Emerald II
(To:seanccc)

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

Announcements


Top Tags