Skip to content

Commit 90680ba

Browse files
committed
Fix repeating of persistent parameter in url
1 parent 1a63088 commit 90680ba

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

assets/datagrid.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -347,27 +347,33 @@ document.addEventListener('change', function(e) {
347347
}
348348
});
349349

350-
351350
window.datagridSerializeUrl = function(obj, prefix) {
352-
var str = [];
353-
for(var p in obj) {
354-
if (obj.hasOwnProperty(p)) {
355-
var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p];
356-
if (v !== null && v !== "") {
357-
if (typeof v == "object") {
358-
var r = window.datagridSerializeUrl(v, k);
351+
var str = [];
352+
let urlPathForPersistentChecking = window.location.pathname;
353+
354+
for (var p in obj) {
355+
if (obj.hasOwnProperty(p)) {
356+
var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p];
357+
if (v !== null && v !== "") {
358+
// fix for persistent nette parameters
359+
if (urlPathForPersistentChecking.includes('/' + v)) {
360+
urlPathForPersistentChecking = urlPathForPersistentChecking.replace('/' + v, '');
361+
continue;
362+
}
363+
if (typeof v == "object") {
364+
var r = window.datagridSerializeUrl(v, k);
359365
if (r) {
360366
str.push(r);
361367
}
362-
} else {
363-
str.push(encodeURIComponent(k) + "=" + encodeURIComponent(v));
368+
} else {
369+
str.push(encodeURIComponent(k) + "=" + encodeURIComponent(v));
370+
}
364371
}
365372
}
366373
}
367-
}
368-
return str.join("&");
369-
}
370-
;
374+
375+
return str.join("&");
376+
};
371377

372378
datagridSortable = function() {
373379
if (typeof $.fn.sortable === 'undefined') {

0 commit comments

Comments
 (0)