2
我有一個按鍵的自定義綁定。當我調用綁定屬性時,它不接受我的事件參數。就我而言,我的財產是一個我想用自己的事件參數激發的功能。是這樣的可能嗎?在下面的示例中,值未定義,但是如何將值傳遞給調用方(viewModel.onKeyPress
)?在Kendo的自定義綁定中添加事件參數?
<div id="body">
<input data-role="combobox" data-bind="keyPress: onKeyPress" />
<div id="output"></div>
</div>
<script>
kendo.data.binders.widget.keyPress = kendo.data.Binder.extend({
init: function (element, bindings, options) {
kendo.data.Binder.fn.init.call(this, element, bindings, options);
var binding = this.bindings.keyPress;
$(element.input).bind("keypress", function(e) {
var values = { a: 1, b: 2, c: 3 };
binding.get(e, values); //DOESN'T WORK!
});
},
refresh: function() { }
});
var viewModel = kendo.observable({
onKeyPress: function (e, values) {
$("#output").append("<div>keyPress (see console.log)</div>");
console.log(e);
console.log(values);
}
});
kendo.bind("#body", viewModel);
</script>
輝煌 - 它精美的作品! – TruMan1