Bernie
Posts: 0
Joined: Fri Jul 27, 2012 2:06 pm

How can pick the value from a mobileList?

Max,
thanks for your help and for always responding so quick.
I am sorry, but I think I asked my question wrong.
Here is the short version of what I want to do:

I do have a list filled by custom java script.
Then I want to click on one of the items to get the label/text value of that item and store it in a local storage variable. That's all.

I can't do it with "Set Local Storage Variable", it's not working with my customized filled list, though it works fine with a list filled by mapping.

When I run the following custom java script as a tap event on the list...

var $CategoryList = Tiggr('mobilelistCategory');
alert($CategoryList.text());

...I get this result:

Image

How can I manage by java script to get "education" as a value to store in a local storage variable when I click on the listitem education and so on?

I am just a java script beginner, so I apologize for my stupid questions.
This specific task seems to me so common and I can't find any a little guideline to achieve that goal. My eyes start already hurting from searching the web for hours and hours.

If you can provide me a real code example on that, you'll become my live saver of the day.

Bernie
Posts: 0
Joined: Fri Jul 27, 2012 2:06 pm

How can pick the value from a mobileList?

Here is how I can read all values from the list:

$CategoryList.children().each(function(index, value) {
var $test = jQuery(this).text();
alert($test+index);
});

Now I only need to know, which index number I was clicking and I am in heaven.
Please help :-)

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How can pick the value from a mobileList?

When you create (display) the list, you would need to add a hidden label to the list that would include either the index or the actual label. When you click on a list item, you would read that value -- and this way you will know on which one you clicked.

Bernie
Posts: 0
Joined: Fri Jul 27, 2012 2:06 pm

How can pick the value from a mobileList?

For all folks who simply were waiting for a few lines of code.
This is how it works:

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) {
var eleli = $('').attr('id', val.Category);
eleli.append('a rel="nofollow"' + val.Category + '/a');
eleli.addClass('clickable').click(function () {
alert($(this).attr('id'));
});
CategoryList.append(eleli);
}
}
});
}

CategoryList.listview("refresh");

Return to “Issues”