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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:02:16+00:00 2026-06-08T08:02:16+00:00

Problem: Events that are set inside a view are not firing after the view

  • 0

Problem:

Events that are set inside a view are not firing after the view is replaced with something else using $element.html(anotherView) and then put back on the page using #element.html(theView).

Example:

var BuggyView = Backbone.View.extend({
    // Event works the at first, but not after the view is replaced, then added back
    //     onto the page
    events:{
        'click #some-element': 'on_click_some_element'
    },
    // This function gets called before the view is replaced by another view, but
    //     not after it is added back into the page the second time
    on_click_some_element:function(event){
        alert('User clicked "some element"');
    }
});

The events work after this code executes:

// Create the new view:
var buggyView = new BuggyView({});
// Add the view to the page
$element.html(buggyView.el);

This code would happen later when the view is replaced on the page with something else:

$element.html(anotherView.el);

After the view is added back onto the page, the events no longer work:

$element.html(buggyView.el);
  • 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-08T08:02:18+00:00Added an answer on June 8, 2026 at 8:02 am

    Most likely when you are removing your view you are also removing the views’ bound events, You probably need to either redelgate your events. or instead of using the (jquery) .remove use .detach.

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

Sidebar

Related Questions

I'm using JQuery to set the HTML inside a div. Something like this: $(div).html(strHtmlBlob);
I have a webpage that plays a 'chime' sound when certain events occur. Problem
i have a problem using the Catch Clipboard Events code found on this link
I want to perfom the same action for 2 different events firing. The problem
i've a performance problem with this query: @event = Event.find_by_sql( SELECT * FROM `IdeProNew_development`.`events`
I keep running into this problem over and over. I have a view with
What's the best way to handle binding events on elements that will be refreshed
I have a function that allows me to drag a something around. My js:
I have a UserControl that incorporates a textbox. I want to set the keyboardfocus
My problem is I am setting the datasource from parent page.But if I set

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.