2

I am trying to build a JQuery Mobile UI which uses upshot for getting data from the service and then uses Knockout.js to bind the values to a list. I am able to populate the data however, the JQuery mobile styles are not getting rendered.

Here is my code. Any help in this regard would be really appreciated.

<h2>Projects (<span data-bind="text: projects().length"></span>)</h2>

<ul data-inset="true" data-bind="foreach: projects" data-role="listview" data-theme="e" data-dividertheme="c" data-filter="true"> 
    <li>
            <a href="#" data-bind="text: ProjectName"></a>
            Project Type : <label data-bind="text: ProjectType"></label>
            Description : <label data-bind="text: Description"></label>
    </li> 
</ul>       
<p></p>

@(Html.UpshotContext(bufferChanges: true).DataSource<ProjectServiceController>(x => x.GetProjects()))

<script type="text/javascript">
    $(function () {
        var dataSource = upshot.dataSources.Projects.refresh();
        var ProjectsViewModel = {
            projects: dataSource.getEntities()
        };

        ko.applyBindings(ProjectsViewModel);        
    });

</script>
user1288411
  • 149
  • 1
  • 10

1 Answers1

0

The refresh() call is asynchronous, so you can provide a callback function that is executed after the refresh. jQueryMobile docs say that if you add items you need to refresh the listview after the items are created: http://jquerymobile.com/demos/1.0.1/docs/lists/docs-lists.html

Here's an example of how you might do that:

var dataSource = upshot.dataSources.Projects.refresh(function() {
    $("ul").listview('refresh');
});
Marcus L
  • 463
  • 4
  • 7