backbone.js - Fat Free router blocks Backbone router, how/when does Backbone router.js work? -


i have backbonejs (bb) project setup. have fat free framework (f3) running server-side code. ask this, please keep in mind i'm learning these 2 web dev tools: when bb router routing? have link in web page matches route in bb router, f3 router keeps trying handle , failing. how these 2 routers work , not interfere?

thanks lot help.

if not using pushstate, backbones routes easy differentiate server routes:

  • /route1
  • /route2
  • /route1#route/a
  • /route1#route/b

the part before hash 1 transmitted server (f3 routes). part after hash corresponds backbone routes.

//f3 routing $f3->route('get /route1',…) $f3->route('get /route2',…)  //backbone routing routes: {   "route/a": "routea",   "route/b": "routeb", } 

note backbone router doesn't generate http request server (unless define of course).

what generates automatically http requests backbone model. backbone model mapped server resource using urlroot. methods fetch(), save() , destroy() mapped respectively get, put , delete http methods.

check example:

usermodel = backbone.model.extend({   urlroot: '/user' }); var user=new usermodel({id:123}); user.fetch();// /user/123 user.save();// put /user/123 user.destroy();// delete /user/123 

on server side, can map user class this:

$f3->map('/user/@id','user'); class user {   function get($f3,$args){…}   function put($f3,$args){…}   function delete($f3,$args){…} } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -