I have used knockout if binding to show/hide a div based on value from model.
var model = {
// Model-----------------------------------------------
router: router,
chosen: chosen,
selectedItems: [],
selectedItemsList: [],
p: {
Id: null,
IsValid : false
},
activate: function (id) {
var self = this;
var apiRoute = 'test/id';
return api.GetModel(apiRoute, null, self);
},
approve: function ()
{
return self.activate(1);
}
};
<!-- ko if: p.IsValid -->
<div></div>
<!-- /ko -->
This works when the application is loaded first time. But to refresh the view I am calling self.activate() in a button click. After calling self.activate(), the show/hide functionality stops working.
Can someone help me identify what is the issue?