I am trying to learn Backbone.StateManager but could not find much material on this. I went through the documentation , but there is no simple example of its use.
I made such an example
(function($) { var UserInputView = Backbone.View.extend({ states: { foo: { enter: function () { alert('hi'); return console.log('enter bar'); }, exit: function () { alert('hi'); return console.log('exit foo'); }, transitions: { transitions: { 'onBeforeExitTo:anotherState': function () { alert('hi'); }, 'onExitTo:anotherState': function () { alert('hi'); }, 'onBeforeEnterFrom:anotherState': function () { alert('hi'); }, 'onEnterFrom:anotherState': function () { alert('hi'); } } } }, bar: { enter: function () { alert('hi'); return console.log('enter bar'); }, exit: function () { alert('hi'); return console.log('exit bar'); }, } }, initialize: function () { var statemanager; alert('intialized'); console.log(this.states); statemanager = Backbone.StateManager.addStateManager(this.states); return statemanager; }, render: function () { alert('render'); } }); var user = new UserInputView(); })(jQuery);
In all of this code, only the intialization function works. The rest of the code does not work. Please direct
source share