Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Weird behaviour with pageable on filtering #166

Open
vinimxit opened this issue Sep 9, 2015 · 0 comments
Open

Weird behaviour with pageable on filtering #166

vinimxit opened this issue Sep 9, 2015 · 0 comments

Comments

@vinimxit
Copy link

vinimxit commented Sep 9, 2015

My Collection:

var $ = jQuery = require('jquery'),
Backbone = require('backbone'),
_ = require('underscore'),
Urls = require('../../libs/urls'),
services = require('../../libs/services'),
skuListModel = require('../../models/sku/SkuListModel'),
PageableCollection = require("backbone-pageable");

var SkuListCollection = Backbone.PageableCollection.extend({
model: skuListModel,
sync: function (method, model, options) {
options = _.defaults({}, options, {
readUrl: Urls.sku.list
});
return services.sync.call(model, method, model, options);
},
state: {
firstPage: 1,
currentPage: 1,
pageSize: 10
},

queryParams: {
currentPage: "page",
pageSize: "limit",
totalPages: this.totalPages
},
searchOnParameter: function (search_string) {
console.log(search_string);
return this.fetch({
data: {
search_string: search_string
}
})
},
parse: function (response) {
if (_.has(response, "metadata")) {
this.totalPages = Math.ceil(response.metadata.record_count / 10);
this.skus = response.records;
this.totalRecords = response.metadata.record_count;
this.currentPage = this.state.currentPage;
return response.records;
}
}
});

module.exports = SkuListCollection;

When i call it in the View

searchData: function (e) {
var self = this;

self.skuCollection.searchOnParameter(e.target.value).then(function (response) {

});

}

It appends the result with the current collection how do i solve this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant