backbone.js - Backbone View injected links reload Site -
after rendering backbone view inject html generated jquery. html includes links within application. if click links reload site.
how can bind links trigger router , don't reload site?
you have bind click event links , call router.navigate
. it's important return false
event handler prevent borwser follow link. important thing pass trigger: true
have router execute (otherwise change url displayed in address bar).
events : { 'click a.changeview' : 'changeview' }, changeview : function(e) { router.navigate(e.target.href, { trigger: true }); return false; }
also, might have tweak href
bit if contains protocol, domain, etc... instance if href
http://mydomain.com/mypage
might need pass mypage
router.
Comments
Post a Comment