title: Programmatic event binding using Kendo UI MVVM not working
body: <p>I'm trying to programmatically bind events to fields. The "data-bind > events > change" attribute(s) is/are being added to the DOM element just fine. For instance, this is the HTML generated by my script:</p>
  
  <pre><code>&lt;select id="MainContent_DetailsContent_TypeOfLoss" class="valid" name="TypeOfLoss" data-role="dropdownlist" data-text-field="text" data-value-field="value" data-bind="source: TypeOfLoss, events: { change: TypeOfLoss_updateSourceUsingValue }" style="display: none;"&gt;
  </code></pre>
  
  <p>However, when I change the value of the <code>DropDownList</code> (just for example), I get the following error:</p>
  
  <blockquote>
    <p><code>TypeError: handler is not a function</code><br>
    <code>path/to/app/Assets/Lib/kendo/src/js/kendo.web.js</code><br>
    <code>Line 6923</code></p>
  </blockquote>
  
  <p>I don't know what's going on - the <code>TypeOfLoss_updateSourceUsingValue</code> method/property DOES exist in the corresponding View-Model (KendoDOMBinder._viewModel).</p>
  
  <p>Any ideas? I'm using kendoui.web.2013.1.319.</p>
  
  <pre><code>KendoDOMBinder: function (viewModel) {
      var binder = Object.create({
          _viewModel: {},
          _widgets: {},
          _root: {},
  
          init: function (viewModel) {
              this._viewModel = viewModel || Object.create(kendo.observable());
              this._widgets = App.Config.Widgets.defaults();
  
              return this;
          },
          bindField: function (node, bindings) {
              var that = this,
                  val = [],
                  ds,
                  events = [],
                  event,
                  target,
                  fnCallback,
                  callback;
  
              // Empty data attributes will crash Kendo
              if (App.Utilities.isEmpty(bindings) === false) {
                  // TODO: Should be using strategy pattern to process data attributes
                  $.each(bindings, function (type, binding) {
                      switch (type) {
                          case 'source':
                              ds = App.Data.DataSource.Factory(binding)
                              val.push(type + ': ' + node.name);
                              that._viewModel.set(node.name, ds);
                              break;
                          case 'value':
                              // Make sure the property doesn't exist before adding it
                              if (that._viewModel.hasOwnProperty(binding) === false) {
                                  // Add the property
                                  that._viewModel.set(binding, '');
                                  // TODO: accept function
                              }
                              break;
                          case 'events':
                              break;
                          case 'field':
                              event = binding.event || 'change';
                              type = binding.type;
                              target = binding.target;
  
                              if (binding.type == 'triggerUpdate') {
                                  fnCallback = [node.name, binding.callback].join('_');
                                  //console.log(fnCallback);
  
                                  // Make sure the property doesn't exist before adding it
                                  if (that._viewModel.hasOwnProperty(fnCallback) === false) {
                                      // Define the callback
                                      switch (binding.callback) {
                                          case 'updateSourceUsingValue':
                                              // Add the property
                                              fnCallback = that._viewModel.set(fnCallback, function () {
                                                  alert("Doing something");
                                              });
                                              //console.log(that._viewModel);
  
                                              events.push(event + ': ' + fnCallback);
                                              break;
                                          case 'updateUsingValue':
                                              break;
                                      }
                                  }
                              }
  
                              break;
                          default:
                              val.push(type + ': ' + binding);
                              break;
                      }
                  });
  
                  if (events.length &gt; 0) {
                      val.push('events: { ' + events.join(', ') + ' }');
                  }
              }
              console.log(val.join(', '));
              node.setAttribute('data-bind', val.join(', '));
  
              return this;
          },
          unbindField: function (key) {
              //this._viewModel.unbind;
  
              return this;
          },
          bind: function (selector) {
              selector = selector || 'body';
  
              kendo.bind($(selector), this._viewModel);
          },
          createFunction: function (ns, fn) {
              var nsArray = ns.split(/\./),
                  currentNode = this._root,
                  newNS;
  
             while (nsArray.length &gt; 1) {
                newNS = nsArray.shift();
  
                if (typeof currentNode[newNS] === "undefined") {
                   currentNode[newNS] = {};
                }
  
                currentNode = currentNode[newNS];
             }
  
             if (fn) {
                currentNode[nsArray.shift()] = fn;
             } else {
                currentNode[nsArray.shift()] = {};
             }
          }
      });
  
      return binder.init(viewModel);
  }
  </code></pre>