Chin
Chin

Reputation: 12712

knockout js - how to tell if model item has changed

I have the following view

<ul data-role="listview" data-inset="true">
 <!-- ko with: model.Item_selected -->          
<li data-role="list-divider" class="stay"><span>Details</span></li>
<span  title="Name" data-bind="text: name"></span>
</li>etc...
<!-- /ko -->
 </ul>

The problem I have is jquery mobile's list is not updating so I need to call the jqmobile list object to reapply the formatting/enhancing. Is there a model change event I can hook into to to let me know when I should be calling a view update list function

Upvotes: 1

Views: 1022

Answers (1)

Tom Maeckelberghe
Tom Maeckelberghe

Reputation: 1999

You need to subscribe http://knockoutjs.com/documentation/observables.html

myViewModel.personName.subscribe(function(newValue) {
    alert("The person's new name is " + newValue);
});

Upvotes: 4

Related Questions