paging done, needs some additional refactoring
This commit is contained in:
@@ -51,24 +51,30 @@ var fetchItemWithDetails = function() {
|
||||
}
|
||||
}
|
||||
|
||||
var fetchItemsByCategory = function(categoryId, query) {
|
||||
var items = _itemsByCategory;
|
||||
var fetchItemsByCategory = function(categoryId, offset, limit, query) {
|
||||
//var items = _itemsByCategory;
|
||||
var items = new ItemCollection();
|
||||
items.clearFilter();
|
||||
items.setClassificationType(2);
|
||||
items.setClassificationId(categoryId);
|
||||
items.setLimit(30);
|
||||
items.setOffset(0);
|
||||
items.setLimit(limit);
|
||||
items.setOffset(offset);
|
||||
|
||||
for(var key in query) {
|
||||
if (query.hasOwnProperty(key)) {
|
||||
if (query.hasOwnProperty(key) && key != 'limit' && key !='offset') {
|
||||
items.addFilter(key, query[key]);
|
||||
}
|
||||
}
|
||||
|
||||
items.fetch({
|
||||
success: function() {
|
||||
success: function(collection, response, options) {
|
||||
var total = options.xhr.getResponseHeader('x-total-count');
|
||||
items.setTotalCount(total);
|
||||
|
||||
ItemStore.emitChange();
|
||||
}});
|
||||
|
||||
_itemsByCategory = items;
|
||||
};
|
||||
|
||||
var fetchBestSellingItemsForSection = function(sectionId) {
|
||||
@@ -78,7 +84,6 @@ var fetchBestSellingItemsForSection = function(sectionId) {
|
||||
items.setClassificationId(sectionId);
|
||||
items.setLimit(30);
|
||||
items.setOffset(0);
|
||||
|
||||
|
||||
items.fetch({
|
||||
success: function() {
|
||||
@@ -147,7 +152,7 @@ AppDispatcher.register(function(payload) {
|
||||
loadItemsForFrontpage();
|
||||
break;
|
||||
case ItemConstants.LOAD_BY_CATEGORY:
|
||||
fetchItemsByCategory(action.categoryId, action.query);
|
||||
fetchItemsByCategory(action.categoryId, action.offset, action.limit, action.query);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user