JQuery sortable only works on browser hard reload (meteor/blaze) -
i used avital's example here: https://github.com/meteor/meteor/tree/master/examples/unfinished/reorderable-list
for reason, in implementation need reload page work. in other words, once app loads in browser, list isn't sortable. refresh browser page , fine.
my implementation:
on client call server method set initial ranks each item in list. note, tried running meteor.call on server inside meteor.startup same result:
meteor.call("setinitialtodosrank")
i add sortable code (from avital's example)
ui.body.rendered = -> # uses 'sortable' interaction jquery ui $('.list-group').sortable stop: (event, ui) -> # fired when item dropped el = ui.item.get(0) before = ui.item.prev().get(0) after = ui.item.next().get(0) newrank = undefined unless before # moving top of list newrank = simplerationalranks.beforefirst(ui.getelementdata(after).rank) else unless after # moving bottom of list newrank = simplerationalranks.afterlast(ui.getelementdata(before).rank) else newrank = simplerationalranks.between(ui.getelementdata(before).rank, ui.getelementdata(after).rank) console.log "newrank #{newrank}." todos.update ui.getelementdata(el)._id, $set: rank: newrank
packages used: iron router, jquery-ui-sortable, hammer, blaze-layout, , iron-router-active.
Comments
Post a Comment