cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear controls and value when navigating between screen.

Former Member
0 Kudos

Hi all,

I have developed a small application for practice which has login screen and once logged there will be sign out button.following are my questions

  • When i click sign out now i simple navigated to the home login page using APP.to  but how to make sure when i click sign out i clear the variable are screens and return to home login page.
  • When try to navigate to already existing page i get error saying cannot create duplicate controls and does not navigate to next screen.I am using XML views
  • What the performance related to tips to be take care while create controls and navigating across views

Thanks

Deepan

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor
0 Kudos

Hi Deepan

In this example, we show that we can use a model to clear the value of a dialog. You may want to adapt it to your case. Of course, you can clear the value. However, we always advocate using model so that we have the MVC in place; and make your implementation cleaner. That's it does not matter, you have using a input control or other controls. So long as the value in the model is clear, the value of the control will be clear accordingly.

Hope this helps.

Thanks

-D

Answers (1)

Answers (1)

scott_stefanich
Active Participant
0 Kudos

Hello Deepan,

For clearing a variable, here is an example using an input control, button, and function. Let's say the input control and button are defined in the XML view as follows,

<Input id="idInput" value="User" />

<Button press="handleLogOut" />

In the controller's handleLogOut function, you can get the view, get the input control by id, and set the value:

handleLogOut : function(){

  this.getView().byId("idInput").setValue("");

}

For duplicate controls, it sounds like duplicate ids are being created. This could happen if you use the same id="x" in an XML view or if controls are being created programmatically with duplicate ids.

For performance tips...that's a good question. Usually, we troubleshoot poorly performing examples, but it would be good to locate a collection of best practices.

Regards,

Scott

Former Member
0 Kudos

Thanks reg the duplicate control if I don't use id will the same control be created again when navigating to same screen again but what about the value it hold will it be cleared??

SergioG_TX
Active Contributor
0 Kudos

You should not use duplicate ids. Having duplicate ids will cause JavaScript errors. Make sure you use distinct control Ids, then follow Scott's suggestion to clear out input values