Pergunta

I'm trying to have my ListView working with Pull To Refresh. Nevertheless, I can't have the listview refresehd.

basically, when a user trigger pull to refresh, it should replace the whole content of the list view.

Here is how I have handled my list view and the pull to refresh:

function handle_geolocation_query( position )
{
    $.when( Event.getEventsNearby( position.coords.latitude, position.coords.longitude, radius, limit, offset, key ) ).done( function( response )
    {
        var dataToBeCached = new Array();

        //In order not to cache the same results twice
        var previousContent;

        if( response.containsResults )
        {
            var results = response.results;

            //Remove previous markers
            Map.clearMarkers();

            // Add Markers on the map
            Map.setMarkerPosition( position.coords.latitude, position.coords.longitude, "grey" );
            for ( var i=0; i<results.length; i++ )
            {
                Map.setMarkerPosition( results[i].lat, results[i].lng, "green");
                results[i]["index"] = i;
            }

            setItem("events", JSON.stringify( results ), 1);

            var template = Handlebars.compile( $( '#eventListTemplate' ).html() );
            $("#list-container").kendoMobileListView({
                template : template,
                dataSource: kendo.data.DataSource.create(results),
                fixedHeaders: false,
                pullToRefresh: true,
                pullParameters: function(item) {
                    console.log("pull");
                    //Here, another AJAX call to get the new results
                    $.when( Event.getEventsNearby( position.coords.latitude, position.coords.longitude, radius, limit, offset, key ) ).done( function( response )
                    {
                        console.log("when");
                        //I can see I'm getting my results properly here.
                        console.log(response.results);
                        //Doesn't work ...
                        return response.results;
                    });
                }
            });

            $( document ).trigger( "wallReady" );

            //Retrieve the different user conversations:
            updateListOfChats();
        }
    } );
};

What should I put into the pullParameters function to make it work ? Thanks.

Foi útil?

Solução

The pull parameters function should return the parameters about to be passed in the next request, which is performed by the datasource component itself. Please refer to the API reference for more details and a working example.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top