.length - Count/Display number of objects in a data string

17 views
Skip to first unread message

gabarinocheka

unread,
Apr 20, 2014, 2:06:42 PM4/20/14
to ampl...@googlegroups.com
I am working on my first ever amplify app that records location,activity, Date of Entry.

The localstorage has the key "__amplify__activities" and the following data:

{"data":[{"location":"mabvuku","activity":"mariro","dateVisited":"2014-04-20T03:27:52.091Z"},{"location":"tafara","activity":"dunhu","dateVisited":"2014-04-20T03:27:59.615Z"},

What I'd like to do is :

1. display the results in batches of 10.
2. display total number of entries.

Any help is appreciated.

gabarinocheka

unread,
Apr 20, 2014, 7:06:35 PM4/20/14
to ampl...@googlegroups.com
Ended up doing it this way (to display total # of entries).


var itemCount = $(data[Object]).length;
if (itemCount < 1){
    $( "#itemCount" ).html("Welcome to activity log. Please add your name.");
      } else {
        $("#itemCount").html("You have  <span class='label'>" + itemCount + "</span>activities.");
}

If there is a better way to do it, please let me know.

Doug Neiner

unread,
Apr 21, 2014, 9:38:44 PM4/21/14
to ampl...@googlegroups.com
Hi there!

Most of what you are doing is fine, but I believe the first line should be this:

var itemCount = amplify.store( "activities" ).length;

Doug
--
You received this message because you are subscribed to the Google Groups "Amplify" group.
To unsubscribe from this group and stop receiving emails from it, send an email to amplifyjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages