Created
February 25, 2016 15:11
-
-
Save hijonathan/7a33056aed38a9852f3f to your computer and use it in GitHub Desktop.
How to add Appcues to your Backbone application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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