javascript - backbone routes, creating a faux route? -
i not sure if have used technical term, or describe wanting backbone routes. in application user logs dashboard , can see activity related them, clicking on activity link create modal them edit activity.
on landing in dashboard url http://app.dev/#dashboard on clicking link want modal overlay dashboard, url change http://app.dev/#activity/edit/:id without losing activity view should site behind model, app navigations edit route , re-renders everything, there way preserve view change url?
you need create subview render edit view (or create overlay popup). either way, cannot using <a href>
tag, need via javascript.
backbone.js has way navigate through routes using:
router.navigate(fragment, options)
- see backbone navigate
using {trigger:true}
can call router function (which happens now) , re-render view using router function (as if user landed on page). default, , if pass {trigger:false}
, backbone change url, not trigger router function, transparent user, besides fact see url change, , can see change in history (if used backbone.history.start()
)
bottom line: change url, without going through router, call router.navigate(requestedurl, { trigger: false})
, don't forget show him new view (popup, overlay, nested view, etc...)
Comments
Post a Comment