Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

kendo.Backbone.ViewEvents

Latest
Compare
Choose a tag to compare
@mxriverlynn mxriverlynn released this 04 Sep 14:41
· 3 commits to master since this release

This release adds an easy way to get Kendo UI widget events directly inside of your Backbone.View instances. You only need to configure a kendoUIEvents object (the same way you configure the events now) and then call the kendo.Backbone.ViewEvents.delegate method after the controls are up and running!

var View = Backbone.View.extend({
  template: "<div id='list'></div>",

  // declare the Kendo UI widget events
  // the same way you would declare the
  // Backbone.View "events"
  kendoUIEvents: {
    "change #list": "listChanged"
  },

  listChanged: function(e){
    console.log("THE LIST CHANGE EVENT FIRED!!!");
  },

  render: function(){
    // render the view however you want
    this.$el.html(this.template);

    // instantiate a Kendo UI widget in the view
    this.$("#list").kendoListView({
      dataSource: {
        data: [{name: "foo"}, {name: "bar"}]
      },
      template: "#= name #"
    });

    // tell the kendo.Backbone plugin to 
    // delegate the view events for 
    // the widgets in this view
    kendo.Backbone.ViewEvents.delegate(this);
  },

  remove: function(){
    // unbind the kendo ui events
    kendo.Backbone.ViewEvents.undelegate(this);
    Backbone.View.prototype.remove.call(this);
  }
});

See the documentation for more information.