What I have:
I navigate through backbone's views via Backbone.history.navigate("someFragment", {trigger: true}) method
What I want:
I'm searching for correct way to pass navigation callback function. Means something like Backbone.history.navigate("someFragment", {trigger: true}, callbackFunction). Important point - I want that callback proceeds ONLY ONCE, and when I call Backbone.history.navigate("someFragment", {trigger: true}) next time, it won't be proceeded.
You should listen to the route event of your router.
myRouter.on('route:someFragment', callbackFunction )
To create a one-time callback you could use underscore's once:
var oneTimeCallback = _.once( callbackFunction );
myRouter.on('route:someFragment', oneTimeCallback )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With