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

  • Home
  • SEARCH
  • 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 7672581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:19:09+00:00 2026-05-31T16:19:09+00:00

I have a router like this, as main entry point: window.AppRouter = Backbone.Router.extend({ routes:

  • 0

I have a router like this, as main entry point:

window.AppRouter = Backbone.Router.extend({
    routes: {
        '': 'login'
    },
    login: function(){

        userLoginView = new UserLoginView();
    }
});

var appRouter = new AppRouter;
Backbone.history.start({pushState: true});

I have a model/collection/view like this:

window.User = Backbone.Model.extend({});

window.Users = Backbone.Collection.extend({
    model: User
});

window.UserLoginView = Backbone.View.extend({

    events: {
        'click #login-button': 'loginAction'
    },

    initialize: function(){
        _.bindAll(this, 'render', 'loginAction');
    },

    loginAction: function(){
        var uid = $("#login-username").val();
        var pwd = $("#login-password").val();

        var user = new User({uid:uid, pwd:pwd});
    }
});

And body of my HTML looks like this:

<form action="#" method="POST" id="login-form">
    <p>
        <label for="login-username">username</label>
        <input type="text" id="login-username" autofocus />
    </p>
    <p>
        <label for="login-password">password</label>
        <input type="password" id="login-password" />
    </p>
    <a id="login-button" href="#">Inloggen</a>
</form>

Note: The HTML comes from Node.js using express.js, should I maybe wait for a document ready event somewhere?

Edit:

I have tried this, create the view when ready, did not solve the problem.

    $(function(){
        userLoginView = new UserLoginView();
    });
  • 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-05-31T16:19:10+00:00Added an answer on May 31, 2026 at 4:19 pm

    It doesn’t look from the code you’ve posted like you’re assigning an el property to the UserLoginView instance. I don’t think the events hash will work to bind event handlers unless the view has an el (that is, a root DOM element for the view – see docs). When you initialize the view, it binds handlers to the root element, using .delegate() for child elements, so no root element, no handlers, even with id-based selectors. Try this:

    window.UserLoginView = Backbone.View.extend({
        el: '#login-form',
        // etc
    });
    

    Note that, as discussed in the comments, you should be doing this after the DOM is ready. The standard approach here is to kick off the router and history machinery in $(document).ready:

    $(function() {
        var appRouter = new AppRouter;
        Backbone.history.start({pushState: true});
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Expressjs w/ node.js and I have a route like this: users.init(app.db, function()
I'd like to call Backbone's router.navigate and have it update the hash fragment only,
I have a route defined like this: GET /question/:q_id controllers.Questions.viewQuestion(q_id: Long) Then in my
I have a route that is suppose to match something like this localhost:3000/site/admin and
I would like to change my default route values. Right now, I have: routes.MapRoute(
I feel like I have everything I need in my routes.rb, my controller, and
I have two backbone Views. One is the main view and the other is
I have a backbone view - which when called presents a form $('#add-offer').click(function() {
I am trying to get a url structure like this. http://example.com/blog/1/title-name-goes-here My main urls
I currently have a routes object that has several regular pages, and would like

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.