Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Clarify documentation #29

ghost opened this Issue Feb 3, 2012 · 2 comments


None yet
2 participants

ghost commented Feb 3, 2012


I'm trying to be successful with Davis.js. Two things are not clear to me:

  1. How to disable the default behavior?
    If I only write Davis() all links are being changed. E.g. when I click on one with href="about.html", it goes no longer to http://example.org/app/about.html, but instead happily goes to http://example.org/about.html.
  2. Is it possible to use Davis.js without jQuery?

olivernn commented Feb 3, 2012

The default behaviour of Davis is to bind to all links and forms. If you had some links, or forms, on you page that you don't want Davis to bind to you can ignore them by changing the selector that Davis uses to find links etc.

Depending on your app you could either explicitly mark all the links you want Davis to bind to with a class or data attribute, or you could do so the other way round, explicitly marking all links you don't want Davis to bind to with a class or data attribute.

var app = Davis(function () {

  // your routes etc here

  this.configure(function () {
    this.linkSelector = 'a:not(.external)'   // if you want to explicitly mark external links
    this.linkSelector = 'a[data-davis=true]' // if you want to explicitly mark davis links

This will make davis only listen to links that match those selectors, obviously you should choose whichever makes most sense for your app.

I have been working on allowing davis to be used without jQuery, this is currently not released but I can push the dev branch if you want to try it out. It should be possible to swap jQuery with Zepto with no changes required, if you want to use something different or no library at all then you will have to implement a few of the methods from jQuery or zepto that Davis relies on.

This was helpful. It would be nice to have it more front and center in the documentation. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment