在knockout.js中禁用锚标签 [英] Disable anchor tag in knockout.js
本文介绍了在knockout.js中禁用锚标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
< a id =aQStreamSkypedata-bind =attr:{href:''},单击:$ parent.StoreUserClick,禁用:($ data。 SkypeId =='null')> Skype< / a>
解决方案
锚定标记无法禁用。最简单的方法是使用 ko绑定
,然后渲染 span
而不是<$如果skype id为null
<! - ko if:c $ c> anchor
skypeId === null - >
< span>无Skype ID< / span>
<! - / ko - >
<! - ko if:skypeId!== null - >
< a id =aQStreamSkypedata-bind =attr:{href:''},点击:$ parent.StoreUserClick,text:skypeId>< / a>
<! - / ko - >
I need to disable the anchor tag inside a foreach loop of knockout.js in HTML.
Here is my code:
<a id="aQStreamSkype" data-bind="attr:{href: ''}, click: $parent.StoreUserClick,disable: ($data.SkypeId == 'null')">Skype </a>
解决方案
Anchor tags cannot be disabled.
The easiest is to use ko if binding
and then render a span
instead of the anchor
if the skype id is null
<!-- ko if: skypeId === null -->
<span >No Skype Id</span>
<!-- /ko -->
<!-- ko if: skypeId !== null -->
<a id="aQStreamSkype" data-bind="attr:{href: ''}, click: $parent.StoreUserClick,text: skypeId"></a>
<!-- /ko -->
这篇关于在knockout.js中禁用锚标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文