2013-02-19 79 views
0

kendocombobox是否有任何onblur事件?我阅读下面的链接,但无法找到任何东西。 http://docs.kendoui.com/api/web/combobox关于kendo combobox的onblur事件

然后我试图改变事件这样下面

$("#selFrameworkVersion").kendoComboBox({ 
     change: function (e) { 
      alert("I am selected"); 
     } 
    }); 

这不火。我已经在我的html中定义了我的kendocombobox,如下所示:

<td><input id="selFrameworkVersion" style="width: 210px" data-bind="kendoComboBox: { dataTextField: 'Name', dataValueField: 'Id', data: $root.versionListByProductType, value: $root.editFrameworkVersion, optionsCaption: 'Please select Version...' }" /></td> 

数据加载正确。在改变事件或onblur事件我想执行一些逻辑。我怎样才能实现它?

我呼吁互联网服务和数据绑定到observablearray(versionListByProductType),你可以看到我有我的观点

$.ajax({ 
      url: "../RestService/Version/VersionListByProductType", 
      type: "PUT", 
      contentType: 'application/json', 
      processData: false, 
      data: JSON.stringify(input), 
      error: function (XMLHttpRequest, textStatus, errorThrown) { 
       alert(errorThrown); 
      }, 
      success: function (allData) { 
       var mappedVersionListByProdType = $.map(allData, function (item) { 

        return new productVersionListByProductType(item); 
       }); 
       self.versionListByProductType(mappedVersionListByProdType); 
       callback(allData); 

      } 

     }); 

回答

0

使用我不知道什么是绑定您正在使用?有没有这样的demo?为什么不这样使用:

input id="selFrameworkVersion" style="width: 210px" /> 
<script> 
$("#selFrameworkVersion").kendoComboBox({ 
    dataSource:["foo","bar"], 
    change: function (e) { 
     alert("I am selected"); 
    } 
    }); 
</script> 

这是jsbin

+0

我正在使用敲除绑定。查看我更新的问题 – DevelopmentIsMyPassion 2013-02-19 20:12:18

1

根据初始化后附加事件的文档,你必须做这样的事情。

// get a reference to instance of the Kendo UI ComboBox 
var combobox = $("#comboBox").data("kendoComboBox"); 
// bind to the change event 
combobox.bind("change", function(e) { 
    // handle event 
}); 
+0

当我使用你建议的方式时,它表示Uncaught TypeError:不能调用未定义的方法'绑定'。我真的不知道在哪里初始化它。我只是把这个代码放在我的viewmodel中 – DevelopmentIsMyPassion 2013-02-20 08:02:37