With Meteor, I want new items that are added to a list to fade in. However, I don't want every element in the list to fade in slowly when something is added, only the new element that is added.
I have the following Collection published by the server and subscribed on the client
List = new Meteor.Collection("List");
Meteor.autosubscribe(function () {
Meteor.subscribe('list');
});
I have the following template:
<template name="list">
{{#each list}}
{{> list_item }}
{{/each}}
</template>
<template name"list_item">
{{ text }}
</template>
I would like to call the following when a new element is inserted into a Collection:
function (item) {
var sel = '#' + item._id;
Meteor.defer(function () {
$(sel).fadeIn();
});
}
I have tried using
List.find().observe({
added: function (list_item) {
var sel = '#' + list_item._id;
Meteor.defer(function() {
$(sel).fadeIn();
});
}
});
However, the function is called for each item in the list when a new list_item is added, rather than only for the single new item.