Meteor Cookbook by Strack Isaac

Meteor Cookbook by Strack Isaac

Author:Strack, Isaac [Strack, Isaac]
Language: eng
Format: azw3, epub
Publisher: Packt Publishing
Published: 2015-05-26T16:00:00+00:00


If we look at the swatches helper inside Template.colors.helpers, we can see that the Mongo Collection.find() query is sorted by rank:

swatches: function(){ return Swatches.find({},{ sort: { rank:1 }}); }

This preserves the order of the swatches in the UI and allows us to manipulate their order as a result of drag and drop.

Inside of our sortable.stop() function, we were identifying where in the list the swatch had been dragged and dropped to. Once we determine where the swatch is located, we calculate a new rank for that swatch using the Rankings helper functions. We then immediately update the swatches collection with the new rank, which propagates and makes the position of the UI change permanent.



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.