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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:33:36+00:00 2026-06-17T01:33:36+00:00

I have a pretty basic Backbone question. I want to apply a class (using

  • 0

I have a pretty basic Backbone question. I want to apply a class (using jQuery) when an element is clicked. Unfortunately I don’t know how to do this with Backbone views – I can capture the click event, but I don’t know how to get the element in a way that jQuery can understand.

My HTML looks like this:

<div id="options">
<ul>
<li>red</li>
<li class="selected">blue</li>
<li>green</li>
</ul>
</div>

UPDATE – sorry, I should have given a less edited-down example, the real HTML is actually like this:

<li><img src="red.jpg"><h3>red</h3></li> 
<li class="selected"><img src="blue.jpg"><h3>blue</h3></li> 
<li><img src="green.jpg"><h3>green</h3></li> 

And my Backbone code looks like this:

var SearchFormView = Backbone.View.extend({
el: $('#options'),
events: {
  "click li": "updateResults"
},
updateResults: function(e) {
  console.log('updateResults');
  $(this).toggleClass("selected");
}

});

It isn’t working as it stands – updateResults is being logged to the console, but the class isn’t being applied. I think this because I’m not using this correctly. Grateful for any advice.

  • 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-17T01:33:37+00:00Added an answer on June 17, 2026 at 1:33 am

    Sup when using backbone events, this is set to the view. try using e.target instead of this.

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

Sidebar

Related Questions

Pretty basic programming question, I know PHP have a function for it, but does
I have a pretty basic question regarding the openxml sdk. I want to process
I have a pretty basic jQuery ajax thing happening, but I want to mix
i have a pretty basic jquery question. im trying to add jscrollpane to my
I have a pretty basic question regarding buttons on HTML pages. As we know,
This is a pretty basic C++ design question: I have a class that contains
I have a pretty basic problem I can't figure out when using jQuery simplemodal:
I might have pretty basic question about regex. I have the following regex, which
I have a pretty basic challenge-based iPhone game, and I wanted to know what
I realize this question is pretty basic, but I'm really stuck. I have a

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.