diff --git a/core/misc/ajax.es6.js b/core/misc/ajax.es6.js index c8c8eb1cd3..beda4f644a 100644 --- a/core/misc/ajax.es6.js +++ b/core/misc/ajax.es6.js @@ -315,6 +315,13 @@ elementSettings.url = href; elementSettings.event = 'click'; } + const type = $linkElement.data('ajax-type'); + /** + * In case of setting custom ajax type for link we rewrite ajax.type. + */ + if (type) { + elementSettings.type = type; + } Drupal.ajax(elementSettings); }); }; @@ -381,6 +388,7 @@ */ Drupal.Ajax = function (base, element, elementSettings) { const defaults = { + type: 'POST', event: element ? 'mousedown' : null, keypress: true, selector: base ? `#${base}` : null, @@ -567,7 +575,7 @@ }, dataType: 'json', jsonp: false, - type: 'POST', + type: ajax.type, }; if (elementSettings.dialog) { diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 75c97f62ab..d6c347bd9f 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -146,12 +146,19 @@ elementSettings.event = 'click'; } + const type = $linkElement.data('ajax-type'); + + if (type) { + elementSettings.type = type; + } + Drupal.ajax(elementSettings); }); }; Drupal.Ajax = function (base, element, elementSettings) { const defaults = { + type: 'POST', event: element ? 'mousedown' : null, keypress: true, selector: base ? `#${base}` : null, @@ -246,7 +253,7 @@ dataType: 'json', jsonp: false, - type: 'POST' + type: ajax.type }; if (elementSettings.dialog) {