backbone.js - triggering events in multiple views -


i'm putting app using backbone.js, has 2 views right now, indexview , quizpartial. indexview renders bulk of page (some graphs , whatnot), , contains many quizpartials. issue when user clicks 'delete' link in 1 of partials, partial should deleted , appropriate model destroyed, while indexview renders button create new quiz. however, can't indexview respond event.

code:

class quizpartial extends backbone.view   tagname: "div"   classname: "quiz"   events:     "click a.delete": "delete_quiz" # works fine    initialize: -> @render()    delete_quiz: ->     if confirm "are sure want delete test?"       $(@el).remove()       @model.destroy()     false 

and index view:

class indexview extends backbone.view   tagname: "div"   id: "quizzes_index"   events:     "click .quiz a.delete": "render_new_quiz_button" # never fires    initialize: -> @render()    # etc... 

is there should doing differently?

thanks!

the actual ui event done within quiz view. correctly remove element , destroy model. have 2 choices:

  • have indexview listen "remove" event on quiz collection.
  • trigger new event quiz view notify whoever listening

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -