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

This sounds like a problem many others have posted about, but there's a nuance
Seen many other similar questions like this on this website and i would say
In c#, I would like the abstract class to be applied to many other
Like many people here, I started my programming experience with the good ol' green
Like many people, I have several SVN repositories that contains several projects. I've decided
We write apps for contract - we have many apps out there, and they
Like many others Knockout developers before me, I encountered a slow running script warning
I, like many others, love Eclipse as my ide of choice, and because of
I am creating dynamic TextFields in actionscript 3.0. Like many others, my text disappears
Like many programmers, I'm prone to periodic fits of inspiration wherein I will suddenly

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.