From 1b3da606b784fa660d7cd39f810e698914d66cd2 Mon Sep 17 00:00:00 2001 From: dannydelott Date: Fri, 17 Jul 2015 14:12:33 -0700 Subject: [PATCH] Add docs for View#events --- index.html | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 28dd63c9..c3e6f3f5 100644 --- a/index.html +++ b/index.html @@ -450,6 +450,7 @@
  • template
  • render
  • remove
  • +
  • events
  • delegateEvents
  • undelegateEvents
  • @@ -2929,6 +2930,36 @@ var Bookmark = Backbone.View.extend({ events that the view has listenTo'd.

    +

    + eventsview.events or view.events() +
    + The events hash (or method) can be used to specify a set of DOM + events that will be bound to methods on your View + through delegateEvents. +

    + +

    Backbone will automatically attach the event listeners at instantiation + time, right before invoking initialize. +

    + +
    +var InputView = Backbone.View.extend({
    +
    +  tagName: 'input',
    +
    +  events: {
    +    "keydown" : "keyAction",
    +  },
    +
    +  render: function(){ ... },
    +
    +  keyAction: function(e) {
    +    var isEnterKey = e.which === 13;
    +    if(isEnterKey){ this.collection.addEntry(this.$el.val()); }
    +  }
    +});
    +
    +

    delegateEventsdelegateEvents([events])
    @@ -4263,7 +4294,7 @@ ActiveRecord::Base.include_root_in_json = false in 1.2.0. - + 1.2.0May 13, 2015DiffDocs @@ -4286,7 +4317,7 @@ ActiveRecord::Base.include_root_in_json = false

  • Views now always delegate their events in setElement. You can no longer modify the events hash or your view's el property in - initialize. + initialize.
  • Added an "update" event that triggers after any amount of