@@ -1300,7 +1300,8 @@
};
function PaginationPerPage(obj, settings) {
- var _this = this;
+ var _this = this,
+ fromUser = true;
this.initOnLoad = function() {
return settings.features.paginate;
@@ -1326,10 +1327,15 @@
};
this.create = function() {
- var $select = $('<select>', {
+ var $select = $('#dynatable-per-page-' + obj.element.id);
+
+ if (!$select.length) {
+ fromUser = false;
+ $select = $('<select>', {
id: 'dynatable-per-page-' + obj.element.id,
'class': 'dynatable-per-page-select'
- });
+ });
+ }
for (var i = 0, len = settings.dataset.perPageOptions.length; i < len; i++) {
var number = settings.dataset.perPageOptions[i],
@@ -1342,14 +1348,22 @@
obj.process();
});
+ if (fromUser)
+ return $select;
+
return $('<span />', {
'class': 'dynatable-per-page'
}).append("<span class='dynatable-per-page-label'>" + settings.inputs.perPageText + "</span>").append($select);
};
this.attach = function() {
+ var element = this.create();
+
+ if (fromUser)
+ return;
+
var $target = settings.inputs.perPageTarget ? $(settings.inputs.perPageTarget) : obj.$element;
- $target[settings.inputs.perPagePlacement](this.create());
+ $target[settings.inputs.perPagePlacement](element);
};
this.set = function(number, skipResetPage) {
Sometimes users of dynatable don't want the library to generate its own elements, but use the ones already present in the page. This patch adds support to do just that for the per-page element. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com> --- lib/packages/jquery/jquery.dynatable.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)