Page 1 of 1

How to store multiple values to navigate?

Posted: Sun Sep 15, 2013 1:46 am
by Gilbert Gomez

I have some rows with a big list of services that I want to order by category, finally I could do that..well, now I wanna navigate to their description page... So, to do that there is a column with the name page of each one. The idea is that while the application is taking the service's name also store the name of the page that is due to link when you click on the button. But it is not working well because it always show the same page.

Sometimes it's a little hard to explain the problem ..So here I leave a pic with the pattern that reflects the application's structure.

Thank for your time

PD: Picture's size is about 1.3Mb, please be patient if does not appear right away

Image


How to store multiple values to navigate?

Posted: Sun Sep 15, 2013 1:49 am
by maxkatz

When you click on an item -- what code do you run to decide to which page to navigate?


How to store multiple values to navigate?

Posted: Sun Sep 15, 2013 9:14 pm
by Gilbert Gomez

Hi Max
Well I tried with this code:

var whatPath = localStorage.getItem("v_Page");
Appery.navigateTo(whatPath, {
transition:'flip',
reverse: false
});

Actually it works just the first time, after that I always get the same page.
and that's my trouble, I don ́t know what to do to make the app remember the value that suppose just got at the time it read the rows.


How to store multiple values to navigate?

Posted: Sun Sep 15, 2013 9:51 pm
by maxkatz

Check what you get for: whatPath -- do a console.log(..) to make sure you get the right value there


How to store multiple values to navigate?

Posted: Mon Sep 16, 2013 6:23 pm
by Gilbert Gomez

Hi Max, how are you?

I was reading some others docs and I found people with similar troubles and they talk about array but I did not understand how to it works.

Well I leave you an image with my app schema.

Image

Here I tried to be more detailed with my trouble showing you where is the column where I wanto to get the value to navigate ...read by a RestService with a "where" parameter as condition to get just those rows with a certain value on its column2. and then mapped with one Datasource to my "MobileList1" control and local storage variable ...and its javaScript code to do that on click events.

Have a nice day
Thanks


How to store multiple values to navigate?

Posted: Mon Sep 16, 2013 7:29 pm
by Maryna Brodina

You need to save Service name (I mean data source name) you're going to invoke not into localStorage, but into hidden Label inside List item. When you click on List item you'll call saved in Label service.


How to store multiple values to navigate?

Posted: Mon Sep 16, 2013 9:23 pm
by Gilbert Gomez

Hi
Thanks for your idea, I tried it already but I can't get the "Label" text value, how can I do that?

I have this code on click List ítem event, but it doesn't work

----------------------------------------------------------

var myPath = Appery('lbPage_set1').text();
alert (myPath);

----------------------------------------------------------

The mapping works well, because in test view shows the PageName catched from the row, but when I click on "List item" ...alert message appears empty


How to store multiple values to navigate?

Posted: Tue Sep 17, 2013 4:16 am
by Gilbert Gomez

I'm trying to get a page name to navigate after a click event, it must be taken from a database ..(to more ferefence look at the image above)

Well I tried to do this through a datasource mapped to a "Label" ..with the intention to read its Text Value to apply it later to the JavaScript code < ...But, even I can see the page name into this label on the Test view... I can read it with this simple code

pre<code>
var myPath = Appery('lbPage_set1')&#46;text();
alert(myPath)
/pre

But making some test... I realise that if I assign a value to the Text property of the Label control, like "hello" ...the previous code actually works ..the alert message says hello.

Test #1
Image

Test #2
Image

how can I read the text property from this tag if it is assigned through a datasource?

Thanks


How to store multiple values to navigate?

Posted: Tue Sep 17, 2013 7:05 pm
by Maryna Brodina

Hello! Sorry for delay. There are two ways:
1) Add Set local storage variable action on List item Click event, set localStorage variable and bind it to existing element. This action in Events list should go before Run JavaScript action and in JavaScript code you can read value from localStorage.
2) Use the following code:
codevar myPath = $(this)&#46;find("[dsid=hiddenLabelName]")&#46;text();
alert(myPath);/code
where hiddenLabelName - name of component nside List item which value you need to read


How to store multiple values to navigate?

Posted: Wed Sep 18, 2013 12:20 am
by Gilbert Gomez

Hi Marina ..thanks a lot.
it works perfectly.. Thanks a lot.

pre<code>
var myPath = $(this)&#46;find("[dsid=lbPath_Cat6]")&#46;text();
Appery&#46;navigateTo(myPath, {
transition: 'slide',
reverse: false
});
/pre

I leave the final code for all those whom have had the same problem, and remember the hidden label that keeps the text/value that you want to read with this JavaScript must to be into a List Item. And the click event is precisely for this control.

Thanks Marina
Have a good day