olivernn / davis.js

RESTful degradable JavaScript routing using pushState
http://davisjs.com
532 stars 58 forks source link

start stop issue #34

Closed somajs closed 12 years ago

somajs commented 12 years ago

Hi there,

Starting and stopping the app straight away doesn't actually stop it, this line still get executed: Davis.$(function () { app.start() })

var app = Davis(); app.start(); app.stop(); // doesn't stop the app

Romu

olivernn commented 12 years ago

I think this is due to a timing issue. Davis tries to start your app as soon as possible, that is when the dom is ready. Therefore if you call stop immediately it is likely going to be before the Dom is ready and therefore the app will be started again when the Dom is ready.

If you really need to delay the start of your app you can just instantiate one manually by doing:

var app = new Davis.App

Then calling start manually whenever you want, as long as it is after the Dom is ready

somajs commented 12 years ago

I see, thanks for the shortcut!