X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9325dabcc2b6c32a589ba86cc052946b4875eb1d..37470b030384ebe8a73e6d1e725cbde4abb924da:/apps/workbench/app/assets/javascripts/select_modal.js diff --git a/apps/workbench/app/assets/javascripts/select_modal.js b/apps/workbench/app/assets/javascripts/select_modal.js index bd68bc8a2f..17b334eb64 100644 --- a/apps/workbench/app/assets/javascripts/select_modal.js +++ b/apps/workbench/app/assets/javascripts/select_modal.js @@ -49,6 +49,7 @@ $(document).on('click', '.selectable', function() { var selection = []; var data = []; var $modal = $(this).closest('.modal'); + var http_method = $(this).attr('data-method').toUpperCase(); var action_data = $(this).data('action-data'); var action_data_from_params = $(this).data('action-data-from-params'); var selection_param = action_data.selection_param; @@ -75,9 +76,17 @@ $(document).on('click', '.selectable', function() { data.push({name: key, value: value}); } }); + if (http_method === 'PATCH') { + // Some user agents do not support HTTP PATCH (notably, + // phantomjs silently ignores our "data" and sends an empty + // request body) so we use POST instead, and supply a + // _method=PATCH param to tell Rails what we really want. + data.push({name: '_method', value: http_method}); + http_method = 'POST'; + } $.ajax($(this).attr('data-action-href'), {dataType: 'json', - type: $(this).attr('data-method'), + type: http_method, data: data, traditional: false, context: {modal: $modal, action_data: action_data}}). @@ -90,8 +99,9 @@ $(document).on('click', '.selectable', function() { message = "Request failed."; } this.modal.find('.modal-error'). - html('
' + message + '
'). - show(); + html('
'). + show(). + children().text(message); }). done(function(data, status, jqxhr) { var event_name = this.action_data.success; @@ -142,7 +152,7 @@ $(document).on('click', '.selectable', function() { return false; } $(''). - attr('href', $form.attr('data-search-modal')). + attr('data-remote-href', $form.attr('data-search-modal')). attr('data-remote', 'true'). attr('data-method', 'GET'). hide().