Can I temporarily disable routing? Or perhaps any observable map?
Basically until a certain condition is met, I want the routing
disabled, and then I want to turn it on. Then again if another
condition is met - I want to disable it again. I never want to have to
set up routes again, as I'm using routing from within a controller.
So I did some research on the code.. and it seems that you can simply do
1) Initialize can.route as usual using can.route.ready()
2) Whenever you need to disable the routing, just run
can.route._teardown(). The _ implies that it is meant for internal use
only I guess, but it does the job, it unbinds the event but keeps the
obersvable map intact, with all the routes.
3) Whenever you need to enable it again, run can.route._setup().
This will simply enable the bindings again. Alternatively, as I'm
using it, you can run can.route.ready() again, which will run _setup,
but also trigger something similar to a manual route request depending
on the current url.
Members of canjs, please feel free to correct me, or come up with a
more recommended use if you feel needed.
Leave a comment on mvcyonder's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic