Commit 80c92435 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Make search results paging work again.

But this time instead of re-running the search every time we
need to navigate to a new page, just remember the search results
and only render the page.
parent d6126ef1
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ Ext.define('Docs.controller.Search', {
                changePage: function(dropdown, delta) {
                    // increment page number and update search results display
                    this.pageIndex += delta;
                    this.search(this.getField().getValue());
                    this.displayResults();
                    // footerClick doesn't fire in IE9,
                    // so keep the dropdown visible explicitly.
                    this.keepDropdown();
@@ -162,7 +162,11 @@ Ext.define('Docs.controller.Search', {
    },

    // Loads results to store and shows the dropdown.
    // When no results provided, displays the results from previous
    // run - this is used for paging.
    displayResults: function(results) {
        results = results || this.previousResults;

        // Don't allow paging before first or after the last page.
        if (this.pageIndex < 0) {
            this.pageIndex = 0;
@@ -183,5 +187,7 @@ Ext.define('Docs.controller.Search', {
            // auto-select first result
            this.getDropdown().getSelectionModel().select(0);
        }

        this.previousResults = results;
    }
});