From cc8aa9e9514b7ad12f0a5bc4e55c80ff93877d39 Mon Sep 17 00:00:00 2001 From: colymba Date: Fri, 14 Mar 2014 13:58:16 +0200 Subject: [PATCH] FIX bulkaction finally take care of url variables properly --- javascript/GridFieldBulkEditingForm.js | 2 +- javascript/GridFieldBulkManager.js | 46 ++++++++++++++++---------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/javascript/GridFieldBulkEditingForm.js b/javascript/GridFieldBulkEditingForm.js index 347c4a1..fdf8d5a 100644 --- a/javascript/GridFieldBulkEditingForm.js +++ b/javascript/GridFieldBulkEditingForm.js @@ -57,7 +57,7 @@ else cacheBuster = '?cacheBuster=' + cacheBuster; $.ajax({ - url: url + '/' + cacheBuster, + url: url + cacheBuster, data: data, type: "POST", context: $(this) diff --git a/javascript/GridFieldBulkManager.js b/javascript/GridFieldBulkManager.js index 41ac56b..846f3cf 100644 --- a/javascript/GridFieldBulkManager.js +++ b/javascript/GridFieldBulkManager.js @@ -95,7 +95,29 @@ onmatch: function(){ }, onunmatch: function(){ - }, + }, + getActionURL: function(action, url) + { + var cacheBuster = new Date().getTime(); + url = url.split('?'); + + if ( action ) + { + action = '/' + action; + } + else{ + action = ''; + } + + if ( url[1] ) + { + url = url[0] + action + '?' + url[1] + '&' + 'cacheBuster=' + cacheBuster; + } + else{ + url = url[0] + action + '?' + 'cacheBuster=' + cacheBuster; + } + return url; + }, onclick: function(e) { var $parent = $(this).parents('.bulkManagerOptions'), @@ -104,12 +126,10 @@ action = $parent.find('select.bulkActionName').val(), config = $btn.data('config'), - url = $(this).data('url'), + url = this.getActionURL(action, $(this).data('url')), ids = $(this).parents('.bulkManagerOptions').find('input.bulkSelectAll:first').getSelectRecordsID(), - data = { records: ids }, - - cacheBuster = new Date().getTime() + data = { records: ids } ; @@ -128,15 +148,12 @@ } } - $btn.addClass('loading'); + $btn.addClass('loading'); if ( config[action]['isAjax'] ) { - //if ( url.indexOf('?') !== -1 ) cacheBuster = '&cacheBuster=' + cacheBuster; - //else cacheBuster = '?cacheBuster=' + cacheBuster; - $.ajax({ - url: url + '/' + action + '?cacheBuster=' + cacheBuster, + url: url, data: data, type: "POST", context: $(this) @@ -147,14 +164,7 @@ } else{ var records = 'records[]='+ids.join('&records[]='); - - if ( window.location.search ) - { - url = url + '/' + action + window.location.search + '&' + records + '&cacheBuster=' + cacheBuster; - } - else{ - url = url + '/' + action + '?' + records + '&cacheBuster=' + cacheBuster; - } + url = url + '&' + records; window.location.href = url; }