backbone.js - underscore sortBy function on a backbone collection unable to identify the objects of the collection -


i have backbone collection sorted. using undescore.js function sortby. below code snippet

sortedcollection = collectiontosort.sortby(function(obj){ return obj.cost; })

but throws me error obj undefined. working when write code below:

sortedcollection = collectiontosort.sortby(function(obj){
obj = json.parse(json.stringify(obj));
return obj.cost; });

my question why couldn't identify obj object inside sortby function though json object unless reconvert json object

a backbone model passed sortby function, not object initialized model with.

sortedcollection = collectiontosort.sortby(function(model){   return model.get('cost') }) 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -