简体   繁体   English

KnockoutJS-attr绑定$ data不起作用

[英]KnockoutJS - attr binding $data not working

I have this: 我有这个:

<a href="javascript:void(0);" data-bind="attr: { onclick: 'CreateChatWindow(\'$data.peer\');'}" class="socialsChat"><img src="~/Content/Styles/Default/Images/Icons/chat.png"/></a>

Now, the output looks like that: 现在,输出如下所示:

<a href="javascript:void(0);" class="socialsChat" onclick="CreateChatWindow('$data.peer');"><img src="~/Content/Styles/Default/Images/Icons/chat.png"/></a>

Why isn't $data.peer getting it's value from my model? 为什么$data.peer不能从我的模型中获得价值?

First, why 'onclick'? 首先,为什么要“点击”? this should be 'click', at least I'm using this at newest version. 这应该是“点击”,至少我使用的是最新版本。 Second, why you use \\'? 第二,为什么要使用\\'? and third, passing arguments to viewmodel methos looks like this 第三,将参数传递给viewmodel方法看起来像这样

data-bind="click: function() { CreateChatWindow($data); }"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM