node.js - How to properly emit a route that will render a view in Backbone -


i have backbone app set allows me list collection of mongodb objects in table, each edit button next them. when edit button clicked, edititem backbone.view calls render() function. user can change values , hit save button. save button saves new values database fine, in save() success callback function tried rendering list view again new values can viewed. works except since rendered view programatically instead of using routes, url in address bar still shows:

http://localhost:3000/#/edit/5199180b2908cbb60b000003 

but want go just

http://localhost:3000/ 

which listview of items.

in addition this, if attempt click edit button same item, nothing happens @ anymore, if click edit other item, works fine. reason, last edited item cannot edited again. here code save function emitted when save button clicked.

save :function(e){                     console.log("saving skill");                     var btn = e.target;                      var id = $('#skillid').val();                     var obj = {                         name: $('#skillname').val(),                         value: $('#skillvalue').val()};                      var updatedskill = new skillmodel({"_id":id});                     updatedskill.fetch();                     updatedskill.set(obj);                     updatedskill.save(null,                     {                         success: function (model, response) {                             console.log("success");                             skillsview.render();                         },                         error: function (model, response) {                             console.log("error");                         }                     });                      return true;                 } 

what correct way re-emit view this?

i figured out. simple, needed:

app_router.navigate('/', {trigger:true}); 

instead of:

skillsview.render(); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -