2

I am developing phonegap application using backbone Js. To enable the back button functionality i am using Backbone.history.start();.

For one scenario, I want to clear all the application history and invalidating the back button feature.

It would be great if anyone will answer.

Thanks in advance.

Nagendra Badiganti
  • 2,099
  • 2
  • 22
  • 30

1 Answers1

4

Checking the Backbone source code I see it's possible to disable Backbone.history with Backbone.history.stop(); so this may give you the expected behaviour.

// Disable Backbone.history, perhaps temporarily. Not useful in a real app,
// but possibly useful for unit testing Routers.
stop: function() {
  Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl);
  clearInterval(this._checkUrlInterval);
  History.started = false;
},
Puigcerber
  • 9,814
  • 6
  • 40
  • 51
  • You're welcome @nagendra. Now you should accept the answer if the issue is solved. Cheers. – Puigcerber Oct 29 '13 at 11:44
  • Actually I am developing the Android Web application using Phonegap and backbone. If I clear or disable the Backbone.history using your function, My app stopped working with the other functionalities. :(:( – Nagendra Badiganti Oct 29 '13 at 12:59
  • Do you know how to limit Backbone.history stack to certain numbers? Ex: My history stack size should be always 15. – Nagendra Badiganti Oct 29 '13 at 13:01
  • 1
    I don't know exactly what do you want to achieve, but maybe this questions can clear a bit your mind: http://stackoverflow.com/questions/14606634/backbone-router-getting-history-length-for-back-button and http://stackoverflow.com/questions/9906648/how-to-keep-a-clean-browser-history-in-a-backbone-js-app – Puigcerber Oct 29 '13 at 14:17