Skip to content

Commit 6137d5e

Browse files
committed
Merge pull request #13 from unbxd/pagination-hosted
Fix pagination to work for hosted backend
2 parents a1f048b + f6512b4 commit 6137d5e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

unbxdSearch.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ var unbxdSearchInit = function(jQuery, Handlebars){
556556
finalParams = this._processURL(urlqueryparams);
557557
}
558558

559-
if(this.options.deferInitRender.indexOf('search') > -1
559+
if(this.options.deferInitRender.indexOf('search') > -1
560+
&& !this.isUsingPagination()
560561
&& finalParams.extra.hasOwnProperty('page')
561562
&& finalParams.extra.page >= 1)
562563
finalParams.extra.page = finalParams.extra.page + 1;
@@ -1345,6 +1346,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
13451346
this.paintSelectedFacets();
13461347
}
13471348
,paintProductPage : function(obj){
1349+
var start = 1;
13481350
if("error" in obj)
13491351
return;
13501352

@@ -1364,24 +1366,31 @@ var unbxdSearchInit = function(jQuery, Handlebars){
13641366
this.getPage() * this.getPageSize() : obj.response.numberOfProducts;
13651367
this.totalPages = Math.ceil(obj.response.numberOfProducts/this.getPageSize());
13661368

1367-
jQuery(this.options.searchQueryDisplay).html(this.compiledSearchQueryTemp({
1368-
query : obj.searchMetaData.queryParams.q
1369-
,numberOfProducts : obj.response.numberOfProducts
1370-
,start: this.productStartIdx
1371-
,end: this.productEndIdx
1372-
})).show();
1369+
jQuery(this.options.searchQueryDisplay).html(this.compiledSearchQueryTemp({
1370+
query : obj.searchMetaData.queryParams.q
1371+
,numberOfProducts : obj.response.numberOfProducts
1372+
,start: this.productStartIdx
1373+
,end: this.productEndIdx
1374+
})).show();
13731375

13741376
this.paintSort(obj);
13751377
this.paintPageSize(obj);
13761378
this.paintPagination(obj);
1379+
obj.response.products = obj.response.products.map(function(product){
1380+
product['unbxdprank'] = obj.response.start + start;
1381+
start += 1;
1382+
return product;
1383+
});
13771384

13781385
if(this.getClass(this.options.searchResultSetTemp) == 'Function'){
13791386
this.options.searchResultSetTemp.call(this,obj);
13801387
}else{
13811388
if(!this.compiledResultTemp)
13821389
this.compiledResultTemp = Handlebars.compile(this.options.searchResultSetTemp);
13831390

1391+
if(this.options.deferInitRender.indexOf('search') === -1 || !this.isUsingPagination()){
13841392
jQuery(this.options.searchResultContainer).append(this.compiledResultTemp(obj.response));
1393+
}
13851394
}
13861395

13871396
if(!this.currentNumberOfProducts && typeof this.options.onIntialResultLoad == "function") {

0 commit comments

Comments
 (0)