我有一个表单,它由几个文本框和一个按钮组成。
我正在使用 Kendo UI MVVM 格式。单击按钮时,如何获取每个文本框的值并将其存储在对象中?
我是否必须使用普通的 jQuery 来获取值,或者是否有其他方法可以从它们中获取值?
谢谢
哈迪克
我有一个表单,它由几个文本框和一个按钮组成。
我正在使用 Kendo UI MVVM 格式。单击按钮时,如何获取每个文本框的值并将其存储在对象中?
我是否必须使用普通的 jQuery 来获取值,或者是否有其他方法可以从它们中获取值?
谢谢
哈迪克
Please take a look at these documentation pages:
http://demos.kendoui.com/web/mvvm/index.html
http://docs.kendoui.com/getting-started/framework/mvvm/observableobject
http://docs.kendoui.com/tutorials/mvvm-in-kendo-ui
These pages contain answers to most of the questions you'll have concerning Kendo UI MVVM. It would be silly and presumptuous of me to think that I could explain it better than the qualified and hard working individuals at Telerik that have so painstakingly compiled these documentation pages.
The gist of it is that you need to create an instance of the kendo.data.ObservableObject
that has properties for the values you are working with. This is your view-model. Then in your markup for your text boxes, include values for the data-bind
attribute that reference the properties in your observable object. Create a function in your view-model to handle the button's click
event. Put a data-bind
attribute in your button that binds the click event to your function. Finally, call kendo.bind(<element>, <observable object>)
, and that will connect the wires from your markup to your view-model object.
In your click event-handler, you can take the values of the view-model, and insert them into the object you need. You should not need to use "normal jQuery" for anything besides referencing the element to call bind
on.
您可以使用 JQuery 以这种方式快速检索值:
$('#yourTextBoxID').data('kendoMaskedTextBox').value();
您可以使用以下代码:
$('#yourTextBoxID').val();