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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:54:05+00:00 2026-05-27T18:54:05+00:00

I have a backbone IndexView which calls a TaskView for each ‘task’ model. I’d

  • 0

I have a backbone IndexView which calls a TaskView for each ‘task’ model. I’d like to bind an event to the li element that wraps the taskview. So for example, the ‘className’ attribute is ‘task’, and I want to trigger an event on ‘.task’.

I can bind from the parent (IndexView) view, but I’d like access to information inside the clicked view, which I’m guessing means the event should be bound to the child TaskView(?)

(Also, DOM classes inside the actual tasks template can be accessed…just not the wrapping .task li)

Any ideas appreciated – code below.

CHILD VIEW

Backbonescaffolddemo.Views.Tasks ||= {}

class Backbonescaffolddemo.Views.Tasks.TaskView extends Backbone.View
  template: JST["backbone/templates/tasks/task"]

  tagName: "li"
  className: "task"

  events:
    "click .task"    : "demoMethod"

  initialize: () ->
    _.bindAll(this, 'demoMethod', 'render')
    console.log @
    #@showTask()
    @el.id = 'sort_order_' + @model.get('id') if @model

  destroy: () ->
    @model.destroy()
    this.remove()
    return false

  demoMethod: () ->
    console.log 'Work dammit, work. Arghhh'

  render: ->
    $(@el).html(@template(@model.toJSON() ))    
    return this

PARENT VIEW

Backbonescaffolddemo.Views.Tasks ||= {}

class Backbonescaffolddemo.Views.Tasks.IndexView extends Backbone.View
  template: JST["backbone/templates/tasks/index"]
  id: "taskList"

  events: 
    "keyup #searchTasks" : "searchTasks"

  initialize: () ->
    _.bindAll(this, 'addOne', 'sortable', 'task_id_from_element', 'addAll', 'searchTasks', 'updateSort', 'sortable', 'render')
    @options.tasks.bind('reset', @addAll)
    @options.tasks.bind('reset', @sortable)
    @options.tasks.bind('add', @render)
    @updateSort()
    @sortable()

  #...

  addAll: () ->
    @options.tasks.each(@addOne)

  addOne: (task) ->
    view = new Backbonescaffolddemo.Views.Tasks.TaskView({model: task})
    $(@el).append(view.render().el)

  render: ->
    $(@el).html(@template(tasks: @options.tasks.toJSON() ))
    @addAll() 
    return this
  • 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-27T18:54:06+00:00Added an answer on May 27, 2026 at 6:54 pm

    Ahh – found it. A straight-out “click” : “demoMethod” (with no specified DOM scope) does the job.

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

Sidebar

Related Questions

I'm using Backbone.js have a segmented control-type UI element for each model's view. They
I have a backbone model which contains an array which I am updating with
I have a Backbone Model: class DateTimeSelector extends Backbone.Model initialize: -> @bind 'change:date', @updateDatetime
I have some Backbone.js code that bind a click event to a button, and
I have a backbone view - which when called presents a form $('#add-offer').click(function() {
I have a Backbone View for a general element that specific elements will be
I have a backbone application which, upon load, needs to fetch data from four
I have a Rails application with the backbone-rails gem. Which works out fine but
I have implemented a simple close() method for all the Backbone views which disposes
I have html content like: <button class=submit>Save</button> and view like: var MyView = Backbone.View.extend({

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.