Skip to content
Snippets Groups Projects
Commit 43c29872 authored by Aaron McGowan's avatar Aaron McGowan Committed by Michael Mol
Browse files

Issue #2981359 by amcgowanca, Coufu: Get coffee.get_data route path and send it via drupalSettings

parent c076cf85
No related branches found
No related tags found
2 merge requests!14Draft: Automated Project Update Bot fixes,!1Change the label class to be sr-only
......@@ -41,8 +41,12 @@ function coffee_page_attachments(array &$attachments) {
$cache_tags = isset($attachments['#cache']['tags']) ? $attachments['#cache']['tags'] : [];
$attachments['#cache']['tags'] = Cache::mergeTags($cache_tags, $config->getCacheTags());
$data_path = Url::fromRoute('coffee.get_data')->toString();
$data_path = ltrim($data_path, '/');
$attachments['#attached']['library'][] = 'coffee/drupal.coffee';
$attachments['#attached']['drupalSettings']['coffee'] = [
'dataPath' => $data_path,
'maxResults' => $config->get('max_results'),
];
}
......
......@@ -73,8 +73,9 @@
var autocomplete_data_element = 'ui-autocomplete';
var urlPath = drupalSettings.coffee.dataPath || 'admin/coffee/get-data';
$.ajax({
url: Drupal.url('admin/coffee/get-data'),
url: Drupal.url(urlPath),
dataType: 'json',
success: function (data) {
DrupalCoffee.dataset = data;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment