Page 1 of 2

Clickable list problem

Posted: Wed Apr 04, 2012 12:02 pm
by mcgrathken.kmg

Hi Max

I'm simply trying to get vaue of a clicked item in my list named "Productlist".
I'm using jQuery function
$('#Productlist li').click(function(){
var $this = $(this);
alert($this.text() + ' \nIndex ' + $this.index());
})

This will not even show alert box.
I am invoke the above on-click event of the ProductListitem.
Perhaps it may be done using Tiggr API ?

Thanks Max


Clickable list problem

Posted: Wed Apr 04, 2012 12:17 pm
by Julia Babenko

You can add Click event on mobilelistitem with this code:

var $this = $(this);
alert($this.text() + ' \nIndex ' + $this.index());


Clickable list problem

Posted: Wed Apr 04, 2012 12:26 pm
by mcgrathken.kmg

Hi Julia

Thanks for that, it worked.
I was calling the function when i didn't need to
Whats the easiest way to store the clicked item into localstorage.
I am using
var prod = localStorage.setitem("key1","value1");

but when i debug in Chrome i cannot see the clicked item in the list.

thanks


Clickable list problem

Posted: Wed Apr 04, 2012 12:39 pm
by Julia Babenko

var prod = localStorage.setItem("key1","value1"); - this should work (correct setItem method)


Clickable list problem

Posted: Wed Apr 04, 2012 3:03 pm
by mcgrathken.kmg

Hi Julia
I have been working on localstorage but i cannot get it to work.
My list if products is named "Productslistitem"
my items which are stored within a label within the list is named "ProductLabel"
what am i doing wrong?
I just want the item clicked stored appended to localstorage.
Tiggzi keeps freezing on me when it tries to do an auto save.
In order to fix this i have to close my browser and reload the app (screenshot below) :-(
Thanks Julia Image


Clickable list problem

Posted: Thu Apr 05, 2012 1:10 am
by maxkatz

It's not clear what the problem is, can you post code and show how it works and how it should work?

As for freezing -- does that happen only if you use autosave or when clicking Save button?


Clickable list problem

Posted: Thu Apr 05, 2012 11:45 am
by mcgrathken.kmg

Hi Max
Sure. I have a a list named "Productslistitem" inside it i have a label named "ProductLabel"

I am trying to store each clicked item in the list to localstorage.
I am using custom javascript on click event of the list.

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

//var prod = $(this);
//alert($this.text() + ' \nIndex ' + $this.index());
var prod = localStorage.setItem("key1","value1");

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

As i have declared var prod i presume that i dont need to set local varible as shown below
Image Image


Clickable list problem

Posted: Thu Apr 05, 2012 11:49 am
by mcgrathken.kmg

The freezing only happens when it auto saves.
This only happens sporadically.
Some days it doesn't happen and other days it happens very frequently.
I understand difficult to pinpoint as answer is very vague, however, I will monitor this strange behaviour and keep you posted
Thanks Max


Clickable list problem

Posted: Thu Apr 05, 2012 12:46 pm
by maxkatz

Is this the code that you use?

code
localStorage.setItem("key1","value1");
/code

It should work but it will overwrite the previous entry on every new click.


Clickable list problem

Posted: Thu Apr 05, 2012 1:24 pm
by mcgrathken.kmg

Hi Max

Yes this is what i use but i dont see anything stored in localstorage.
It should be storing all clicked items in the list.
They are all strings so it should be ok.