From b3f4fc2b52646a165aac5251f89fcaddd9f29a27 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 24 Sep 2013 13:19:41 -0500 Subject: [PATCH] Fix search result buttons issue --- changelog | 4 ++++ www/assets/js/callbacks.js | 41 ++++++++++++++++---------------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/changelog b/changelog index e97c1fae..72760976 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +Tue Sep 24 13:15 2013 CDT + * www/assets/js/callbacks.js: Instantiate a new paginator for every + search result- prevents buttons being incorrectly added or omitted. + Mon Sep 23 16:22 2013 CDT * lib/user.js: distinguish search result return packets with a 'source' field that specifies where the item came from (e.g 'yt' for youtube diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 4582c07a..15013131 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -939,33 +939,26 @@ Callbacks = { clearSearchResults(); }) .insertBefore($("#library")); - var p = $("#library").data("paginator"); - if(p) { - p.items = data.results; - p.loadPage(0); - } - else { - var opts = { - preLoadPage: function () { - $("#library").html(""); - }, + var opts = { + preLoadPage: function () { + $("#library").html(""); + }, - generator: function (item, page, index) { - var li = makeSearchEntry(item, false); - if(hasPermission("playlistadd")) { - addLibraryButtons(li, item.id, data.source); - } - $(li).appendTo($("#library")); - }, + generator: function (item, page, index) { + var li = makeSearchEntry(item, false); + if(hasPermission("playlistadd")) { + addLibraryButtons(li, item.id, data.source); + } + $(li).appendTo($("#library")); + }, - itemsPerPage: 100 - }; + itemsPerPage: 100 + }; - p = Paginate(data.results, opts); - p.paginator.insertBefore($("#library")) - .attr("id", "search_pagination"); - $("#library").data("paginator", p); - } + var p = Paginate(data.results, opts); + p.paginator.insertBefore($("#library")) + .attr("id", "search_pagination"); + $("#library").data("paginator", p); }, /* REGION Polls */