Val*_*lay 4 kendo-ui kendo-mvvm
请在下面找到我的代码:
客户搜索表单模板
<script type="text/x-kendoui-template" id="customer-search-view-template">
<div class="searchform" id="searchCustomer">
<form class="frmSearch">
<input name="searchTxt" data-bind="value: customerName" class="k-textbox" />
<button class="k-button" data-bind="click: searchClicked">Search</button>
<button class="k-button" data-bind="click: newClicked">New</button>
</form>
</div>
</script>
Run Code Online (Sandbox Code Playgroud)
customer-search.js 在哪里加载上面的模板并创建 viewmodel 对象
$(function(){
var views = {};
templateLoader.loadExtTemplate("customer-search-view-template", "../views/customer-search-template.html");
var layout = new kendo.Layout($('#customer-search-view-template').html());
layout.render($("#main"));
// Create an observable view model object.
var customer = kendo.observable({
customerName: "John",
searchClicked: function() {
this.set("customerName", "Search clicked");
},
newClicked: function() {
this.set("customerName", "New clicked");
}
});
// Bind the view model to the personFields element.
kendo.bind($('#searchCustomer'), customer);
});
Run Code Online (Sandbox Code Playgroud)
当我单击搜索按钮时,文本设置在文本框中,但这也会?searchTxt=Search+clicked在地址栏中刷新页面。
我可以知道为什么单击此按钮会刷新页面以及如何在单击按钮时停止刷新页面吗???
小智 5
我会尝试为每个人放置属性“类型”,如下所示:
<button type="button" class="k-button" data-bind="click: searchClicked">Search</button>
<button type="button" class="k-button" data-bind="click: newClicked">New</button>
Run Code Online (Sandbox Code Playgroud)
该页面认为每个人都在执行一个表单提交操作,但是通过放置 type 属性,您可以访问您打算搜索的事件。如果您不打算发布任何数据,而只是一个 js 事件处理程序,则您可能不需要表单标签。祝你好运。
| 归档时间: |
|
| 查看次数: |
3385 次 |
| 最近记录: |