Thursday, 15 August 2013

Using Knockout.Js, how to do refresh the ul when new data is binding to li?

Using Knockout.Js, how to do refresh the ul when new data is binding to li?

Really i'm struggling with knockout js for couple of days. because I'm new
to this technology. I'm unable to do refresh the ul when new data is
binding to li. Given below is my code.
<ul data-role="listview" id="ListSearch" data-divider-theme="b"
data-inset="true" >
<li data-role="list-divider" role="heading">
Criteria Selected
</li>
<!-- ko foreach: Contacts -->
<li data-theme="c">
<a href="#page3" data-transition="slide" data-bind="attr: {
title: ContactID }">
<span data-bind="text: FirstName + ' ' + LastName + ' ('
+ Classification +':'+ Position+ ')'"></span>
</a>
</li>
<!-- /ko -->
</ul>
Jquery Ajax Call:
$.ajax({
url: 'http://localhost:50043/api/contacts/filter',
type: 'GET',
dataType: 'jsonp',
data: { ID: ClassificationPositionid },
context: this,
success: function (result) {
self.Contacts(result);
$('#ListSearch').listview("refresh"); //throwing error.
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
$(".divLoading").hide();
alert(errorThrown);
}
});
ListSearch is the id of UL. If i given as like above then it throwing
below error.
Uncaught TypeError: Object [object Object] has no method 'listview'
How to fix this error? Please help me where I made mistake

No comments:

Post a Comment