Skip to content

Instantly share code, notes, and snippets.

@hijonathan
Created February 25, 2016 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hijonathan/7a33056aed38a9852f3f to your computer and use it in GitHub Desktop.
Save hijonathan/7a33056aed38a9852f3f to your computer and use it in GitHub Desktop.
How to add Appcues to your Backbone application.
var AppRouter = Backbone.Router.extend({
beforeNavigate: function(fragment) {
// Put code you want to run before the URL changes.
},
afterNavigate: function(fragment) {
// Put code you want to run after the URL changes.
// Wait for all other javascript to finish running, then call Appcues.
window.setTimeout(function() {
if (Appcues != null && Appcues.start != null) Appcues.start();
}, 0);
},
navigate: function(fragment, options) {
this.beforeNavigate.call(this, fragment);
Backbone.history.navigate(fragment, options);
this.afterNavigate.call(this, fragment);
return this;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment