关于如何处理Knockout的有活力的意见(通过ja子电话)的互联网,有点信息,但是否有动态观点的最佳实践?
例如,我有一页的对应数据,根据作用、用户选择、环境等,使(通过亚x)不同类型的形式(有不同的投入领域)出现差异。 不仅我使用每种形式的模板,而且我也希望对意见模型采取同样的做法,因为每一种观点都可能具有许多不同的特性,而且每个可能的模板都采用一种大规模的观点模式是不切实际的。
我是ko的灯光,可能无意以这种方式使用。 任何建议都受到高度赞赏。
关于如何处理Knockout的有活力的意见(通过ja子电话)的互联网,有点信息,但是否有动态观点的最佳实践?
例如,我有一页的对应数据,根据作用、用户选择、环境等,使(通过亚x)不同类型的形式(有不同的投入领域)出现差异。 不仅我使用每种形式的模板,而且我也希望对意见模型采取同样的做法,因为每一种观点都可能具有许多不同的特性,而且每个可能的模板都采用一种大规模的观点模式是不切实际的。
我是ko的灯光,可能无意以这种方式使用。 任何建议都受到高度赞赏。
采取这种方式的一个受欢迎的方法是拥有主见模式。
这里是界定具有模板和相关数据的“模拟”物体的真正基本例子。
function Model(key, template, data) {
this.key = key;
this.template = ko.observable(template);
this.data = data;
}
var viewModel = {
models: ko.observableArray([
new Model("user", "userTmpl", { first: "Bob", last: "Smith" }),
new Model("item", "itemTmpl", { name: "MyItem", description: "Here are some details" })
]),
selectedModel: ko.observable()
};
ko.applyBindings(viewModel);
然后,你可以这样使用:
<select data-bind="options: models, optionsText: key , optionsCaption: select a model... , value: selectedModel"></select>
<hr />
<div data-bind="with: selectedModel">
<div data-bind="template: { name: template(), data: data }"></div>
</div>
<script id="userTmpl" type="text/html">
<span data-bind="text: last"></span>, <span data-bind="text: first"></span>
</script>
<script id="itemTmpl" type="text/html">
<h3 data-bind="text: name"></h3>
<div data-bind="text: description"></div>
</script>
显然,你一定会把选择该模式当作一种选择,但它有助于表明它能够如何工作。 你们的模式不是一阵列,而是与钥匙相匹配的财产名称的物体。
“模型”物体中的“数据”是你的分调查模型。
I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...
I m trying to find a reusable way to set focus from one text box to another upon enter using ASP.NET, but using client-side JavaScript to do so. The only reason I mention this is to be done in ASP....
I have some Javascript JQuery code that does an Ajax call to the server every 5 mins, it s to keep the server session alive and keep the user logged in. I m using $.ajax() method in JQuery. This ...
Why are my AJAX requests failing? I have a website www.foo.com, and I m running Tomcat on the same server, www.foo.com:8080/services. However, when a file on foo.com makes an ajax call as such: $....
I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...
I have a entry form. Below it, I want to show a grid containing existing records. As the user clicks on a row of the grid, the values must get filled in the fields of the form above. Is there any way ...
I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...
Ok, I m stumped. Basically, this script works fine in FF, but not in IE (6,7 or 8) - in which it returns an "Object doesn t support this property or method" error. Any ideas?: function ...