javascript - Unable to add model to backbone collection at specified index -
hi trying add model backbone collection specific index i.e. index = 0
i using following code so
updateposts: (postmodel) -> @postscollection.add(postmodel, {at: 0})
however, {at: 0} did not seem take effect model still appear @ bottom of list
initial display of collection (2 items) before adding new modal:
after adding new 'postmodel':
as can see latest model text "completed 'recorded meals' today" appeared @ bottom of list instead of top.
how can resolve latest added model appear on top of list?
- try looking @ collection object itself, in-fact adding index 0 or not.
- try re-rendering entire collection after (to see if render item)
- if both of fail try sorted list (info below)
https://github.com/marionettejs/backbone.marionette/wiki/adding-support-for-sorted-collections
Comments
Post a Comment