0

I have a bootstrap dropdown, with badges in the items. I think this is not so complex, but I can't do this:

<ul class="dropdown-menu" role="menu" data-bind="foreach: events">
    <li><a href="#" data-bind="text: $data.name"><span class=" badge pull-right" data-bind="text: $data.value">NUMBER FROM MODEL TOO</span></a></li>
</ul>

My problem, that binding is working li items are generated, but the li's innerHtml's have just the text, not the text + span with binded number.

How can I do this?

1 Answer 1

1

If you use the text binding on the a tag, its entire content will be replaced by $data.name. To also display the value along with the name, you can do this:

<ul class="dropdown-menu" role="menu" data-bind="foreach: events">
    <li><a href="#"><span data-bind="text: $data.name"></span><span class=" badge pull-right" data-bind="text: $data.value">NUMBER FROM MODEL TOO</span></a></li>
</ul>

Fiddle: http://jsfiddle.net/JUEth/2/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.