Getting Started with Meteor.js JavaScript Framework - Second Edition by Isaac Strack

Getting Started with Meteor.js JavaScript Framework - Second Edition by Isaac Strack

Author:Isaac Strack [Strack, Isaac]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2015-06-30T00:00:00+00:00


First, we check to see whether cats and cats.items are not undefined/null.

Next, we iterate over all the values in items (items is an array, if you recall). To make it easier, we declare the variable itm = cats.item[i].

Then, we add the Lendee property, checking to see whether the item is lent to anyone with the LentTo property. If it isn't (if LentTo doesn't exist), we'll assign the "free" string instead.

Likewise, if LentTo exists, we declare the red bootstrap label class, label-important, as the LendClass. If the item is not lent out, we'll use the green bootstrap class, label-success, instead.

Finally, with our new Lendee and LendClass properties assigned, we'll return cats.items. We didn't save these properties to our data collection. This is because they're not part of the data collection. They're used by the Blaze to modify the look and feel of our UI, so we'll only need to make them available via the template helper.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.