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 7750391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:16:47+00:00 2026-06-01T11:16:47+00:00

I am having problems getting my backbone.js view events to fire. When I click

  • 0

I am having problems getting my backbone.js view events to fire. When I click #login-button nothing is happening.

I am also using iCanHaz (http://icanhazjs.com/) to load the templates.

Here is my javascript:

$(function() {
 var router = new App.Router;
 Backbone.history.start();
});

App.Router = Backbone.Router.extend({
 routes: {
    "login": "login"
 },

login: function() {
    var view = new App.Views.LoginView;
 }
});

App.Views.LoginView = Backbone.View.extend({

 el: '#login',

 initialize: function() {

    _.bindAll(this, 'render', 'validateLogin');
    this.render();

 },

 render: function() {
    App.Stage.html(ich.loginView());
 },

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

 validateLogin: function(event) {
     console.log("validateLogin fired.");
 }

});

Here is my markup (using ICanHaz.js):

<script id="loginView" type="text/html">
        <div data-role="page" id="login" class="container">
            <div class="hero-unit">
                <div class="row-fluid">
                    <div class="span12">
                        <div class="form-horizontal">
                        <fieldset>
                            <legend>Please login to continue</legend>
                            <div class="control-group">
                            <label class="control-label" for="username">Username</label>
                            <div class="controls">
                                <input type="text" class="input-xlarge" id="username">
                            </div>
                            </div>

                                <div class="control-group">
                            <label class="control-label" for="password">Password</label>
                            <div class="controls">
                                <input type="password" class="input-xlarge" id="password">
                            </div>
                            </div>

                                <div class="form-actions">
                        <button id="login-button" class="btn btn-primary btn-large">Login</button>
                    </div>
                        </fieldset>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </script>
  • 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-01T11:16:48+00:00Added an answer on June 1, 2026 at 11:16 am

    I figured it out. Backbone was binding the events to the el before it was created. In the callback for the asynchronous iCanHaz call, I used this.setElement(‘#login’) and it worked perfectly. From the backbone.js documentation:

    setElement [view.setElement(element)]
    

    “If you’d like to apply a Backbone view to a different DOM element, use setElement, which will also create the cached $el reference and move the view’s delegated events from the old element to the new one.”

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

Sidebar

Related Questions

I am having problems getting at a click event of a button and am
I'm having problems getting AppendHeader to work properly if I am also using an
I am having problems getting validation to work for a form built using Zend_Form.
I'm having problems getting a div to appear using jquery after 5 seconds. right
I'm having problems getting gdb to pause execution flow under NetBeans. The pause button
I'm having problems getting my assets folder to upload to the root, but also
I'm having problems getting fb connect working on subdomains. the connect button comes up
So, running the newest ubuntu server and im having problems getting the view to
I am having problems getting JBoss to inject an environment variable value into a
I am having problems getting the 'ByAccount' aggregation to work in SQL Server Analysis

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.