可以'我无法使用knockoutJS进行数据绑定
Can't get my data-binding with knockoutJS to work
我目前正在使用DurandalJS、BreezeJS和KnockoutJS开发一个应用程序。
一切都很顺利,但最简单的事情(我相信(,我无法让它发挥作用。
在我的Viewmodel中,我有一个currentCustomer,它是ko.observable。通过微风我得到了客户!currentCustomer(data.results[0].Customer());
一切正常。如果我用谷歌浏览器查看,我会发现对象中充满了currentCustomer。
我想要的是:我有一个inputfield,通过值数据绑定,我试图将currentCustomer的Name绑定到这个输入。但我不能让它发挥作用。什么是有效的:
<input data-bind="value: currentCustomer()" />
但在输入字段中,它只显示[Object-Object],所以currentCustomer中肯定有一些东西。
这是我尝试过但没有成功的:
<input data-bind="value: currentCustomer().Name()" />
<input data-bind="value: currentCustomer().Name" />
<input data-bind="value: currentCustomer.Name()" />
<input data-bind="value: currentCustomer.Name" />
<input data-bind="value: currentCustomer()._latestValue().Name()" />
<input data-bind="value: currentCustomer()._latestValue.Name()" />
这是一张截图,这样你就可以看到视图中的值了!
http://s22.postimg.org/62m21nnsx/problem_data_bind.png
您尝试过使用'with'吗?
<div data-bind='with:currentCustomer'>
<input data-bind="value: Name/Name()" />
</div>
将其更改为currentCustomer((.name,如果name是currentCustomer实体上的属性,则这应该有效。
相关文章:
- 在VanillaJS中模拟模型双向数据绑定
- Telerik rad组合框多列数据绑定
- AngularJS数据绑定与KnockoutJS数据绑定
- 动态插入Div会破坏KnockoutJS数据绑定
- 使用 Knockoutjs 的数据表数据绑定
- 围绕数据绑定库(如 AngularJS/KnockoutJS)创建抽象
- 使用 KnockoutJS,如何将数据绑定到来自同一视图模型的 2 个不同的<选择>标签
- KnockoutJS的多个数据绑定-值和javascript函数
- 使用PagerJS的KnockoutJS在数据绑定后停止工作
- 如何在JSON中使用Knockoutjs的数据绑定函数
- 在嵌套的ul上使用knockoutjs数据绑定
- 获取数据绑定的元素(使用KnockoutJS)
- KnockoutJS没有绑定数据
- 如何添加自定义数据绑定到knockoutjs'模板绑定
- 可以'我无法使用knockoutJS进行数据绑定
- 我如何将数据绑定到knockoutjs中的特定位置
- KnockoutJS数据绑定:从javascript点击中点击
- KnockoutJs中的条件数据绑定
- 使用prettyCheckable插件与knockoutjs 2.1检查数据绑定不工作
- 当与绑定一起使用时,KnockoutJS的数据绑定不起作用