Stéphan
Stéphan

Reputation: 327

Prevent click event from firing subscribe in knockout model

I have a list of categories that when clicked shows their related items. I can also select the category from a dropdown. If I change the dropdown selection, the same action gets called. But when I click on a category, the dropdown cannot be refreshed the way I did it and I can't figure out a clean way to do it.

Here's a fiddle to demonstrate my problem

Update: I've managed to get it working by basically adding another observable for the category Id and use it to update as reflected in the fiddle.

Upvotes: 0

Views: 509

Answers (1)

Rango
Rango

Reputation: 3907

Just change <li> binding to:

<li data-bind="click: $parent.selectedCategory">

and comment:

self.showItems = function(category){

    // ...

    // self.selectedCategory(category);

    // ...
}

http://fiddle.jshell.net/AWfE8/60/

Upvotes: 1

Related Questions