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

The Archive Base Latest Questions

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

I have this view in Backbone that changes its events depending on a users

  • 0

I have this view in Backbone that changes its events depending on a users action.

So I have three views, all have been initialized.

var view1 = new MainView({el : '#view1'});

var view2 = new ProductsView({el : '#prodcuts'});

var view3 = new StoresView({el : '#stores'});

Now what I want to do is copy events from one view to another and then updating the views el. I’ve tried:

if($option == 'products') {
  view1.events = view2.events
  $("div[data-role='content']", view1.el).html(content);
} else {
    view1.events = view3.events
  $("div[data-role='content']", view1.el).html(content);
}

The problem is that even now the content is the same, and the elements are there that correspond with the events BUT the events are no longer firing. Why is this and how can I fix it?

  • 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-14T12:40:48+00:00Added an answer on June 14, 2026 at 12:40 pm

    You need to call the delegateEvents method.

    For example something like the following (given the code you provided).

    if($option == 'products') {
      view1.delegateEvents(view2.events)
      $("div[data-role='content']", view1.el).html(content);
    } else {
        view1.delegateEvents(view3.events);
      $("div[data-role='content']", view1.el).html(content);
    }
    

    Also note that for removing events you use the undelegateEvents() method.

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

Sidebar

Related Questions

So I have this dilemma, where I have a backbone view that creates a
I have following code: App.Views.UseCategory = Backbone.View.extend({ template: HandlebarsTemplates['uses/useCategory'], initialize: function() { _.bindAll(this, 'render',
I have this backbone that is working fine, i just want to render the
I have two backbone Views. One is the main view and the other is
I have a select box that gets populated through a Backbone Collection: class Prog.Views.History
I am new to Backbone.js. I have created a View for a button that
So I have a View that looks like this. //base class var SelectListView =
I have a Backbone View that uses iScroll to implement a slideshow. iScroll publishes
I have two functions that loop through all models in a Backbone collection, and
I have this view @model IEnumerable<ViewModelRound2> ... <snip> ... @{ using (Html.BeginForm(new { round1Ring3Bids

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.