'refresh' a component

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

'refresh' a component

#1

Postby Steve James » Fri Jan 23, 2015 9:58 am

I have a part page component. The main form has a button to 'add new address'.

On click I hide the table of addresses and show the panel containing the 'add address' part page component.

This works well. On conclusion on the component I hide the component panel and show the table (complete with new address).

The problem comes when I want to add multiple addresses. Next time I press the 'add new address' button the component shows the final stage of the previously added address.

How do I get the component to refresh / restart? Is is possible?

Thanks
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Fri Jan 23, 2015 2:52 pm

It sounds like you need to clear the fields in the component when the add new address button is clicked. For example, if I have a component installed with prefix A_COMP1 which contains fields ADDR1 and ADDR2 , the Javascript code will be:

Code: Select all

components.A_COMP1.fields.ADDR1 = null;
components.A_COMP1.fields.ADDR2 = null;
The code assist should give you a list of available component prefixes and then show the fields available within each component.
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#3

Postby Steve James » Mon Jan 26, 2015 12:50 pm

Thanks Jon, The component is quite old and full of panels which show/hide, tables, fields etc.

I was hoping for something more like

Code: Select all

components.A_COMP1.refresh()
Intellisense suggested it may be possible, ho hum.

I'll rework it.
Thanks
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#4

Postby Jon » Mon Jan 26, 2015 2:15 pm

Afraid not, control.refresh() does something a bit different. But you might find that control modifiers is an acceptable way of clearing a whole load of fields. You flag all the Field Controls on a page that you want to refresh with a modifier (General section of all controls) - say "refreshable". Then you can clear them all with code like this:

Code: Select all

for each (var ctrl in pages.MYPAGE.getControlsByModifier("refreshable"))
{
   var f = ctrl.field;
   if (f)
   {
      field.value = null;
   }
}
This way you don't end up with lots of messy code.
0 x


Who is online

Users browsing this forum: No registered users and 20 guests