I am performing paging using knockout.js .The problem is
JobActivity = function ()
{
var self = this;
self.arraytoadd = ko.observableArray();
/This is the array i am putting the data in from ajax call
self.currentPage = ko.observable(1);
self.perPage = 5;
self.pagedItems = ko.computed(function () {
self.dummy();
var pg = this.currentPage(),
start = this.perPage * (pg - 1),
end = start + this.perPage;
return self.arraytoadd().slice(start, end);
}, this);
self.nextPage = function () {
if (self.nextPageEnabled())
this.currentPage(this.currentPage() + 1);
};
self.nextPageEnabled = ko.computed(function () {
return this.arraytoadd().length > this.perPage * this.currentPage();
}, this);
self.previousPage = function () {
if (this.previousPageEnabled())
this.currentPage(this.currentPage() - 1);
};
self.previousPageEnabled = ko.computed(function () {
return this.currentPage() > 1;
}, this);
} //END OF DECLARING JOBACTIVITY
-------------------------jquery dialog------------
This paging is in a juery dialog.Every time i navigate to next page and cancel the dialog and reopen the dialo it is not showing page1 but instead page2. ISSUE I AM HAVING IS PAGEDITEMS above is not refreshing after i cancel the dialog.Can anyone help me how do i enforce pageditems to start from page1 always when it opens.