Page 1 of 2

How can pick the value from a mobileList?

Posted: Tue Nov 20, 2012 2:56 am
by Bernie

I filled a mobileList with values from a Json file
(CategoryList.append('a rel="nofollow"'+val.Category+'/a');)

Everything works fine. All my entries are shown in the list.
Now I want to pick the value of any of those list entries and pass it to the local storage. How can I do that? I tried this.value, but without luck.

Any suggestions appreciated.


How can pick the value from a mobileList?

Posted: Tue Nov 20, 2012 4:00 am
by maxkatz

Use click event, and save a value into local storage. You will find an example here: http://help.gotiggr.com/getting-start...


How can pick the value from a mobileList?

Posted: Tue Nov 20, 2012 4:48 am
by Bernie

I used the click event. It works, but the result is always an empty value.
Is it, cause I did not map anything?
When mapping, the results of the json entries always end up in a label that is inside the list item. I d not have a label inside my list items.


How can pick the value from a mobileList?

Posted: Tue Nov 20, 2012 4:57 am
by Bernie

Here is the complete coding of how I filled the list:

var CategoryList = Tiggr('mobilelistCategory');
CategoryList.empty();

var count = data.Entries.length;

for (var i=0; i < count; i++) {

$.each(data, function(key, val) {
if (i 0) {
if (val.Category != val[i-1].Category) {
CategoryList.append('a rel="nofollow"'+val.Category+'/a');
}
}
});
}

CategoryList.listview("refresh");


How can pick the value from a mobileList?

Posted: Tue Nov 20, 2012 4:57 am
by maxkatz

Well.. you do need to map something. Did you see the example in the previous post? When you display the list, you would add a hidden value. That hidden value you would save into local storage on click.


How can pick the value from a mobileList?

Posted: Tue Nov 20, 2012 4:59 am
by Bernie

ok, got you. Will do so.Thanks


How can pick the value from a mobileList?

Posted: Tue Nov 20, 2012 9:05 pm
by Bernie

Image

I am sorry to bother you again. I'm simply not getting the value of the selected list item. I do not want to pass it to another page. I only need to have that value.

I've tried with running a script as a click event on the multilistitem:
var $this = $(this);
alert($this(1).text());

== no value

The suggested way described under http://help.gotiggr.com/getting-start... desn't work either. Saving the Text property in a local storage variable returns null!

I've got the feeling, that something is wrong with populating the list on the screen. It appears to be right but behaves some kind of strange.

When mapping my restservice, passing variables over with the local storage worked always fine in the past. But this time I had to fill my list with java script instead of mapping it, because the array I need comes with duplicates I don'T want to display on the scren.

Thanks


How can pick the value from a mobileList?

Posted: Wed Nov 21, 2012 1:27 am
by maxkatz

$(this) -- probably won't work as it returns the current element which is a jQuery Mobile component. If you need traverse the DOM and select the label component from this element. Then you will be able to save it into local storage.


How can pick the value from a mobileList?

Posted: Wed Nov 21, 2012 2:02 am
by Bernie

I get the mobilelist and add my values with mobilelist.append...
Can you give an example how to fill the labels of my list? Do I have to use toArray() ?


How can pick the value from a mobileList?

Posted: Wed Nov 21, 2012 5:04 am
by maxkatz

Well.. by labels I mean the text value that you have in the list. So you don't actually have to create them, they are already there.