Knockout if, click and visible snap

Very simple question.

Let's say I have this HTML in my view ():

<a id="btnXYZ" class="" data-bind="click: editAction">Button</a>

A simple anchor tag that will execute editActionwhen clicked.

Now, if I have something like this:

<a id="btnXYZ" class="" data-bind="click: editAction, if: isOwner(ref)">Button</a>

Let's say isOwner(ref)it is true, I see an anchor without text. Not good.

The expected result will be the same as before (first example).

And now I will say that I have something like this:

<div class="">
    <a id="btnX" class="" data-bind="click: editAction, if: isOwner(ref)">Button</a>
    <a id="btnY" class="" data-bind="click: editAction, if: isOwner(ref)">Button</a>
    <a id="btnZ" class="" data-bind="click: editAction, if: isOwner(ref)">Button</a>
</div>

As before, if isOwner (ref) evaluates to true, see empty anchor tags.

Question:
How can I bind if: isOwner()to control the visibility of buttons?

..
isOwner(ref) true, /
isOwner(ref) false, /

+4
2

, :

<!-- ko if: isOwner(ref) -->
    <a id="btnXYZ" class="" data-bind="click: editAction">Button</a>
<!-- /ko -->

, , - , :

<!-- ko ifnot: isOwner(ref) -->
    whatever you want
<!-- /ko -->
+5

visible. , if .

.

@Vladimirs , , .

0

All Articles