Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9048773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:14:07+00:00 2026-06-16T12:14:07+00:00

I am trying to explore Backbone.StateManager but couldn’t find much material on this. I

  • 0

I am trying to explore Backbone.StateManager but couldn’t find much material on this.
I have gone through the documentation but there is no simple example of using it.

I have made an example like this

(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 this code only intialization function is working. Rest of the code is not functioning. Please guide

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:14:08+00:00Added an answer on June 16, 2026 at 12:14 pm

    Basically, your code misses a state change and a correct target for Backbone.StateManager.addStateManager. As stated in the documentation, to use Backbone.StateManager with objects

    StateManager provides an easy method to painlessly add a StateManager
    to any object. StateManager.addStateManager takes a target object and
    an optional set of options, reads in any states defined on the target,
    and creates a new StateManager. It also sets a number of methods on
    target, including triggerState, getCurrentState, and a reference to
    the StateManager at target.stateManager.

    which means that the target for Backbone.StateManager.addStateManager should be your object instance and that you can start changing state with model.triggerState. For example :

    var UserInputView  = Backbone.View.extend({
        states: {
            // your states
        },
        initialize: function () {
            var statemanager;
            statemanager = Backbone.StateManager.addStateManager(this);
        }
    });
    
    var user = new UserInputView();
    user.triggerState('foo');
    

    A demo based on your code, to visualize some state manipulations

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to explore Skipfish by Google I went through their documentation , and
I explore other threads on stackoverflow, I explore the web but couldn't find the
I asked this question earlier and am now trying to explore the idea of
Im trying to replicate an effect as seen on http://www.fiat.co.uk/Showroom/#showroom/punto_evo/explore . I have made
I am trying to explore behaviors with expression blend. I have seen the mouse
I am trying to explore a graph here but I am not sure what
I've taken everything up to pre-calculus in college, but when trying to get through
I am also trying to explore the fedlet + adfs federation. What I have
I am learning SQL and am trying to learn JOINs this week. I have
I have just started to explore zf2 and trying to install modules. have downloaded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.