Hi All,
What is the best practice to pass a parameter to another view , E.g when a button is clicked.Currently we use button get/setText but I don’t think this is the right way.
Thanks
Atanas
Hi All,
What is the best practice to pass a parameter to another view , E.g when a button is clicked.Currently we use button get/setText but I don’t think this is the right way.
Thanks
Atanas
Hi Atanas,
What are you referring to here when you say ‘parameter’? I imagine calling getText on a button you’ve clicked isn’t going to result in particularly useful information, for example?
Regards,
Nick.
Hi Nick,
Imagine I have a page1 which represent a list of items(each one represented as a button).I have a second view (page 2) as well and I want to pass item id from page1 to page 2 so that be able to keep track which item was clicked.
Currently it was implemented with get/setText so that when a button is clicked nUIEventCallback method that handles the sent event receive the button object with text which is the id of the item.
Hi Atanas,
I think the simpler alternative there is to reference the nuiid of the incoming object in the nUIEventCallback method. Assuming the buttons are being given incremental id’s (e.g. NUIID_MY_BUTTON_ID0, NUIID_MY_BUTTON_ID0 + 1, NUIID_MY_BUTTON_ID0 + 2, …), you could use this value to determine which button has been pressed. What you do with this value is then obviously up to you.
Regards,
Nick.
That is quite coupled with the order of items in the list.That would work if the list of items is static but I rather meant list which is populated dynamically at runtime.What is getText property of nUIButtonElement used for?
Hi Atanas
I made it in exactly the way Nick has described. I have an array of items (populated dynamically when the item list is shown), and based on it I build a list where each button gets NUIID = (NUIID_MY_BUTTON_ID0 + index) of the array item. Based on that index, when I click the button I make a transition to the “details” of the selected item.
When I go back from details view to the item list view, I refresh the list.
Best regards
Javier