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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:51:37+00:00 2026-05-27T09:51:37+00:00

Like many other users out here I have a problem with el and events.

  • 0

Like many other users out here I have a problem with el and events. In my situation I have tested multiple solutions including, using the default el (just <div></div>) setting tagName, setting el to a selector using a jQuery selector and waiting for the DOM to be ready. Each of these solutions have failed at binding the events and all but the default el and tagName have failed at generating html.
Relevant code:

View

$ ->
   class Aggregator.Views.Streams.StreamView extends Backbone.View
      template:JST["backbone/templates/stream"]
      el: $('.item')
      events:
       "click div" : "testing"
      initialize: (model)->
       console.log @el
       _.bindAll this , 'render'
       @model.bind 'change', @render
       @model.view = @
       @render()
       @delegateEvents()
      render: ->
       $(@el).html  "test"
       console.log @el
       @
      testing: ->
       alert "EVENT"
       #@model.clear()

Function that calls view (extracted from another view)

view = new Aggregator.Views.Streams.StreamView({model: stream})
    console.log view.el
    $(@el).append view.render().el

I’m a bit confused, I have set el but it either doesn’t create or it doesn’t bind events. I’ve tried waiting for the DOM to load and passing el to the constructor but no success. Any help on my most likely obvious mistake would be appreciated.

  • 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-27T09:51:38+00:00Added an answer on May 27, 2026 at 9:51 am

    Sorry i’m not comfortable with coffeescript, though i think i recognised your event hash

    events: {
      "click div" : "testing"
    }
    

    and i bet you are trying to bind this testing function to the click on your general view element?
    there is the problem.

    what your click event actually does (selector-wise) is:

    $('div', viewElement).click(fn);
    

    meaning, you don’t target the viewElement div but div’s INSIDE your view element.

    if you want to bind to the general view element itself,
    define an event without a selector

    in your case:

    events: {
      "click" : "testing"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Like many other SharePoint users, I've had to create a custom list definition. After
So I have a User model that :has_many other models like Documents, Videos, Posts
In Ruby, like in many other OO programming languages, operators are overloadable. However, only
I'd like to enable/disable some other controls based on how many items are in
Like many of you, I have to deal with a large amount of files:
In an app, Users and Cases have a many-to-many relationship. Users pull their list
We write apps for contract - we have many apps out there, and they
Like many others on this site I am considering a move to ASP.NET MVC
I, like many others, love Eclipse as my ide of choice, and because of
Like many of you, I use ReSharper to speed up the development process. When

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.