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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:54:13+00:00 2026-05-31T08:54:13+00:00

Im using backbone, require.js and coffeescript in a application. Programming my app, discovered i

  • 0

Im using backbone, require.js and coffeescript in a application. Programming my app, discovered i have a problem with the views. Sorry for my english ! =)

My dom is :

<div id="header"></div>
<div id="container"></div>

Part of my app :

class AppRouter extends Backbone.Router
     routes:
        '': 'home'
        'u/:user': 'user'
        'events: 'events'
        'messages': 'messages'

    events: () ->
        events = new EventsView
        events.events()
    messages: () ->
        messages = new MessagesView
        messages.messages()

class MessagesView extends Backbone.View 
    template: window.Handlebars.compile MessagesTpl
    el : '#container'
    events :
        'click #test' : 'test'

    test: () ->
         console.log 'test'

    messages: () ->
         #fecth and bind render method on 'all'

class EventsView extends Backbone.View
    template: window.Handlebars.compile EventsTpl
    el : '#container'

    events: () ->
         #fetch and bind render method on 'all'

I have the following problem :

When I instance and call in the router (“messages”) the messagesView, i do a fetch and the render works fine. Then when the router navigate to the other route (“events”) and call eventsView, same thing happens, it renders the view correctly.

But if navigate again on the route “messages” the event “test” is fired two times ! , once for each instance !

I discovered if i call on the router $(“#container”).unbind() previous instance MessagesView , this fix the problem, but i dont know if my solution its really good.

My fear is that the DOM is being created evil and have high load. You know you can do with this?

Very thanks for all ! grettings from Argentina !

Alejandro

  • 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-31T08:54:15+00:00Added an answer on May 31, 2026 at 8:54 am

    Your solution is fine, you’re just unbinding and rebinding the events, should not be a problem. Because you use the same dom element, you have to render the view again, but normally that is not too heavy. I’ve used the same solution.

    Alternatively, you could have separate dom elements for MessagesView and EventsView, create the views the first time the user goes to the route. Then you always hide and show the dom elements depending on the current route.

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

Sidebar

Related Questions

I'm in the process of creating a Backbone.js app using Require.js. Each view file
I've been messing around with a backbone.js app using require.js and a handlebars templates
I'm using require.js to help organize my Backbone.js based application. I'm trying to figure
I am building a js heavy app using backbone.js. One problem I've run into
I am using backbone.js for creating an application. I have code JS code as
I am using backbone to build my web app. Currently I am facing an
I'm using backbone's underscore templating engine with the mustache formatting patterns. I have already
I'm building an app using Brunch and Backbone.js that is to include nested menus.
I'm using node.js and backbone for a web app. Backbone is part of my
I'm using Backbone.js in a Rails app and I need to do file uploads

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.