Home > stately

stately

Stately is a project mainly written in JavaScript, based on the MIT license.

A simple implementation of view states for Backbone.js

Stately. Simple state management for Backbone.js Views.

References:

http://documentcloud.github.com/backbone/

Links:

To suggest a feature, report a bug, or general discussion: http://github.com/bigbangtechnology/stately/issues/

Documentation:

http://github.com/bigbangtechnology/stately/docs/stately.html

Use Cases:

I'll get to that.

Example:

Check out the tests for some example usage. You mix Stately into Backbone Views like this:

var MyView = Backbone.View.extend(Stately).extend({ transitions: { state_a: {

},

state_b: {
    // states do not need to define any transitions
},

state_c: {
  before_transition: function() {
    // before transition
  },

  after_transition: function() {
    // after transition 
  }
}

},

getState: function() { return this.nextState; },

// example, in practice you'd probably want to listen // for changes in your model and update your state based // on that setState: function(state) { this.nextState = state;

this.revalidateState(function() {
// during transition
});

} });

var view = new MyView({ model: Backbone.Model() });

view.setState("state_c");

Previous:MyTest