Adding numerical page links
We can now add as many links as are required in order to allow the user to visit any of the pages directly. These are the numerical page links that link to each single page directly.
Engage Thrusters
First of all we need to add a new observable property to our ViewModel, directly after the existing observables in sortable-table.js
:
pages: ko.observableArray(),
After this we can add a new method to our ViewModel. This can be added after the goToPrevPage()
method, within the vm
object literal:
changePage: function (obj, e) { var el = $(e.target), newPage = parseInt(el.text(), 10) - 1; vm.currentPage(newPage); }
Don't forget to add a comma after the goToPrevPage()
method! We can then add a new computed observable, in the same way that we have previously. This can come directly after the createPage
computed observable that we added in the last task:
vm.createPages = ko.computed(function () { var tmp = []; for (var x = 0; x < this.totalPages...