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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:53:26+00:00 2026-06-14T21:53:26+00:00

Some extremely simple problem for those experienced with backbone, but still, an answer here

  • 0

Some extremely simple problem for those experienced with backbone,
but still, an answer here would very helpeful. Not looking for an functional answer, but more about what’s really happening on this specific example.

With the following code (some simple add/remove from favorite)

render: function() {
    $(this.el).html(this.model.get('name'));
    $(this.el).append("<span class='unfav'>remove</span>");
    $(this.el).append("<span class='fav'>add</span>");
    if( this.model.get("selected") == true ){
        $(this.el).addClass("selected");
    } // Should we really need to have an 'else' conditions here that removes the clas :( ? sound weird to me.
    return this;
}

Full code here http://jsfiddle.net/eHAfY/3/
(thanks to @cymen for the codebase)

After adding an element,

Don’t get why the item gets changed when I click on ‘Add’, and does not when I click on remove : if there is a condition that have effect when true, why it is the class’ still here when false ?

  • 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-14T21:53:28+00:00Added an answer on June 14, 2026 at 9:53 pm

    Your render method wipes its inner HTML with $(this.el).html(...); which is what render methods are usually expected to do.

    With $(this.el).addClass("selected"); you modify the external container only when model.selected is true, and your view has no way to know that it should remove this class when the condition is false.

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

Sidebar

Related Questions

I am trying something very simple, but for some reason it does not work.
Doing some homework here (second assignment, still extremely green...). The object is to read
I know that the answer to this is going to be extremely simple and
This is extremely simple but I am wondering why people write this? div#some_id You
I'm having an annoyingly stubborn problem here, and I would appreciate it if anyone
I am doing some extremely large array processing. I do a global declaration of:
I've been getting some extremely bizarre behaviour where NHibernate queries start to hang. I've
We have a client who desires some extremely long pages. Say 4000px plus. They
This is extremely strange, and I'm hoping someone will have some insights to make
Hey all I'm extremely new to jquery and ajax and I'm looking for some

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.