nl_tokens: Actually starts the application s lifecycle . run () should be invoked within a document . ready block to ensure the DOM exists before binding events etc . ### Example var app = $ . sammy ( function () { ... } ) ; // your application $ ( function () { // document . ready app . run () ; } ) ; ### Arguments * start_url Optionally a String can be passed which the App will redirect to after the events / routes have been bound .
pl_tokens: function ( start_url ) { if ( this . isRunning ( ) ) { return false ; } var app = this ; // actually bind all the listeners $ . each ( this . listeners . toHash ( ) , function ( name , callbacks ) { $ . each ( callbacks , function ( i , listener_callback ) { app . _listen ( name , listener_callback ) ; } ) ; } ) ; this . trigger ( 'run' , { start_url : start_url } ) ; this . _running = true ; // set last location this . last_location = null ; if ( this . getLocation ( ) == '' && typeof start_url != 'undefined' ) { this . setLocation ( start_url ) ; } // check url this . _checkLocation ( ) ; this . _location_proxy . bind ( ) ; this . <mask> ( 'location-changed' , function ( ) { app . _checkLocation ( ) ; } ) ; // bind to submit to capture post/put/delete routes /*
        this.bind('submit', function(e) {
          var returned = app._checkFormSubmission($(e.target).closest('form'));
          return (returned === false) ? e.preventDefault() : false;
        });
        */ // bind unload to body unload $ ( window ) . bind ( 'beforeunload' , function ( ) { app . unload ( ) ; } ) ; // trigger html changed return this . trigger ( 'changed' ) ; }