Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ajax]

Use it for questions about JavaScript/PHP code to create asynchronous web applications.

0
votes
0answers
11 views

control views contextual filter; ajax

I would like to implement a view exposed filter that filters by Year. I need to use ajax. I do not want to create a new field that saves the year as a simple integer and instead use the existing built-...
3
votes
1answer
45 views

How to add autocomplete to a textarea on a form?

I would like to add autocomplete functionality to a textarea form element in Drupal 8. I have a fully functioning custom textfield which has autocomplete working on the same form. I have confirmed ...
0
votes
1answer
18 views

Using JCF with dynamic forms

I want to use Javascript Custom Forms (JCF) to get more attractive and consistent looking forms on my Drupal 7 site. I've got it working to a degree, however when the form changes with AJAX, the new ...
0
votes
0answers
12 views

Ajax error on form submit

When I submit the form on the website(example: http://www.megatechnika.ru/node/109/ ) the form isn't sent to the server. And there is an alert showing with /system/ajax/ 500 error and a following text:...
0
votes
0answers
21 views

Call an ajax command after another one ends?

I have a group of ajax commands that I must execute, but there is one that should only be executed once another has been completed. How can I call another ajax coamdo only when another one is ...
0
votes
0answers
43 views

Ajax link not working when in Twig loop

I am trying to create ajax links in a twig template (not in a form) in Drupal 8 and have run into a strange phenomenon. I have managed to create a simple link that opens an alert. This works when I ...
0
votes
0answers
28 views

views exposed filter does not use enabled ajax [on hold]

how do i get the ajax feature to work with exposed filters? am i missing configuration options? what do i need to check? i am using drupal 8.6.1 and a couple of views extensions (better exposed ...
0
votes
1answer
14 views

Custom Ajax forms with managed_file form element

We have a form with three fields - where depending on the value of the first select field, we will show the other two form elements - one select field (the options depends on the value of the first ...
0
votes
1answer
24 views

is there an alternative for hook_views_ajax_data_alter in drupal 8?

As the title sais, is there a similar behavior like hook_views_ajax_data_alter in drupal 8 like in 7? If not has anyone achived the same result programatically? Thanks in advance.
0
votes
0answers
12 views

Link with callback function

How can I build a link with callback function like this, but without necessity of href: $form['link']= [ '#type' => 'link', '#ajax' => [ 'callback' => 'myFunctionCallback', '...
0
votes
1answer
22 views

Commands character limit?

I have 2 functions in a custom AJAX callback which are really confusing me, one returns an image from a single node, the other retrieves a list of nodes first, then loops through them and returns ...
-3
votes
0answers
39 views

How do I hide an AJAX form? [closed]

I use AJAX for the login form, on Drupal 8. After the user is authorized, the message "Hello, username! To see the website as a registered user go to this link." is shown, but the form remains. How do ...
-2
votes
0answers
30 views

How do I fix these errors?

I am facing the below errors while trying to add a block inside a region from /admin/structure/block. It is giving a Javascript warning and errors. Please help me resolve this error. I am not sure ...
0
votes
0answers
31 views

How do I add an error and welcome message?

How do I add an AJAX error and welcome message? I am using the following code, but it's not working. function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) { if ($...
0
votes
0answers
26 views

Views Load More/Infinite Scroll Programmatically

I would like to render a Drupal 8 view programmatically. I know how to do it the Drupal way with Views::getView($view_name). The thing is I want different templating for the first 3 items of the 9 ...
-1
votes
0answers
7 views

How it's possible to include node_load and node_view to ajax_command_html

I have something like this function blogy_html_callback($form, $form_state) { $string = $form_state['values']['search_block_form']; $query = db_select('node', 'n'); $query->join('...
0
votes
1answer
23 views

Pass list from Jquery to form

I have an AJAX form that I've created into a block exposed on my current page. I will have an interface that will allow the users to select an indefinite amount of content to be used within the submit ...
0
votes
1answer
27 views

cant loop through array with ajax_command_html [closed]

im beginner in drupal and i would like to ask why is this not looping , it just gives me first result $string = $form_state['values']['search_block_form']; $query=db_select('node','n'); $query-&...
0
votes
0answers
23 views

use-ajax Class does not work if used in multiple views?

What seems like a pretty straight forward implementation of ajaxifying a link is not working if I use it in more than one view block on the page. I have a route that calls a function. In my view I ...
0
votes
1answer
25 views

Changing form field requirement via ajax

I have a selectbox field, that should change the disabled and required states of another field based on the value selected in the selectbox field. The change must be done via ajax. In my modules ...
0
votes
1answer
18 views

AJAX ReplaceCommand executes as expected only on first iteration

Expected Output: User triggers remove item button. Program updates database. Form gets rebuild with updated information from the database. AJAX replaces the old information with new information from ...
0
votes
1answer
39 views

Modal Form Submission

I have a modal form that I added to my module and patterned it after this article. I have used it before with no issues, I was able to use the method to show the form and then save the data. Now ...
0
votes
0answers
20 views

AJAX Form Not Submitting Until After Cache Clear

I'm working on a module that needs to add a form to a page that submits via AJAX. My form consists of a text field and a submit button with callback: $form['my_text'] = [ '#type' => '...
0
votes
0answers
20 views

Form submit doesn't work first time

When orgno changes brreg_field_ajax_callback is called, company field is filled by js (And it's ok, work fine); but when i click on submit (there are other fields, without #ajax) the page is refreshed ...
0
votes
0answers
21 views

Submit handler not called when loaded Ajax

Form submit handler is not called when form is loaded via ajax in a page. function hook_menu(){ $items['fetch_info'] = array( 'page callback' => 'fetch_info_ajax', 'access callback' => ...
0
votes
0answers
56 views

How to add new elements to draggable table

Hi I'm having some issues with a table to add new elements ive created a form with a draggable table if a add elements manually the table show weight and thats ok but i want to add new elements when ...
0
votes
0answers
18 views

Add binding to “keyup” or “input” to an autocomplete textfield

I have an autocomplete textfield with an #ajax callback on autocompleteclose: $form['myfield-container'] = array( '#type' => 'container', '#attributes' => array( 'class' => array( ...
0
votes
0answers
45 views

Ajax form: Rebuild form and show popup

On my ajax submit form I would like to rebuild the form and show a dialog. Here's the code I have used. public function buildForm(array $form, FormStateInterface $form_state) { if ($some_condition == ...
0
votes
0answers
19 views

Form API states not working when form loaded via Ajax

Drupal form #states not working when I am loading form via jQuery Ajax. $form['activity_container_' . $i]['new_comment_' . $i] = [ '#type' => 'textarea', '#title' => t('Your ...
0
votes
0answers
15 views

no data is stored in cache_form table (Ajax 200 error)

I am using Drupal 7.59 and Drupal Commerce 7.x-1.14. After we updated our PHP version from 5 to 7 and migrated our database to AWS RDS. We started getting a lot of Ajax 200 error(Invalid form POST ...
2
votes
0answers
44 views

How to change the title of a modal window?

I have a link that displays a modal window. The link redirects to a page view. When I click on it, it is marked in the title of the modal window Array. How to customize the title ? <?php ...
0
votes
1answer
28 views

How to execute ajax into block view

I'm in Drupal 7. I would like to execute an ajax function in my front-page. I've defined the block view in my ".module" file. When I change the selected option, the log gets two errors: 1. Warning:...
0
votes
0answers
35 views

Product selection gets progressively slower resulting in AJAX HTTP Error

I am getting the below error when using drop-down select boxes to adjust pricing. I was initially getting it using product variants on about the 7th selection. I have sense ditched the product ...
6
votes
1answer
470 views

How to prevent an Ajax form from submitting

The below code blocks any non-ajax form from submitting. $(this.form) .on('submit', function(event) { if (/* Some condition */) { event.preventDefault(); } }); In Drupal 8, how can ...
0
votes
1answer
22 views

How do I update the CKEditor text widget using CKEditor API

I am using Drupal 8's Ajax API to update form fields in a form depending on the input in another field. One of the fields I want to update is a text_format field that uses Drupal's ckeditor. If I ...
0
votes
2answers
59 views

Language detection by domain breaks ajax requests over https

What do I have: Drupal 8.6.2 Domain Access Language modules Cloudflare with https Problem: If in URL language detection option (/admin/config/regional/language/detection/url) I have "Path prefix"...
0
votes
1answer
25 views

Off canvas dialog using a button

I am trying to adapt the relatively new off canvas dialog introduced in Drupal 8.5. It is suggested to use it with the Drupal Form-API and a link element like this: $form['off_canvas'] = [ '#title'...
1
vote
1answer
29 views

Is the AJAX from image fields and multi-line fields breaking my JavaScript?

We have added tooltips to our node form using this method: https://inclusive-components.design/tooltips-toggletips/ It includes a JavaScript/jQuery snippet that works perfectly except... If the ...
0
votes
1answer
36 views

How to iterate over AJAX-added form elements

In this snippet, located under src/Form/DocumentCreationForm.php, I create an AJAX callback that adds more section elements to the form when the add section button is clicked. Now I'm trying to read ...
0
votes
1answer
22 views

Failed to load popup dialog with in views

I am using Drupal 8.6.1 with the 8.x-1.0-alpha2 Footable module and the core dialog. What I did so far: Install the Footable module. Download the most recent 3.x.x version of the FooTable jQuery ...
0
votes
0answers
24 views

How can I iterate over dynamically added form elements?

I got AJAX working with the AppendCommand, so that every time the Add button is clicked, a new "section" is added to the form. How do I iterate over all these elements in the validation and ...
0
votes
0answers
23 views

Sending ajax message using jQuery

I am using better exposed filters on my view and I need functionality, so that a second click on the same filter would reset filtering at all and give back all results, sadly I didn't find a solution ...
0
votes
0answers
21 views

How to Regenerate CSRF token on Ajax callback handler

For some reasons, I don't want to rebuild the whole form on Ajax, but I want to regenerate CSRF token on ajax callback handler, Is there any way to regenerate form CSRF token on ajax callback handler?...
0
votes
1answer
28 views

Alter existing form and add element with an ajax “add more” button

I am altering the field settigns form, in order to add custom settings. I used the example module as a guide and added my code in the following manner: /** * Implements hook_form_FORM_ID_alter() for ...
0
votes
1answer
31 views

My Ajax call for my submit button does not work?

I am building a form with the form builder but I can't even get my button to use its ajax function to callback. Instead of doing a normal ajax call on the page, it reloads the entire page. What am I ...
0
votes
0answers
54 views

Contextual filter in media browser view not accessible on autocomplete filter ajax call

I'm having a view which filters Media type and has contextual filter of Entity browser context. This view also has an exposed filter of text box field with autocomplete enabled which filters by media ...
1
vote
1answer
32 views

Drupal behaviors not attached after Ajax load

I'm facing a weird problem on my clean Drupal Installation I attached a js library to page with this function fs_gal_preprocess_page(&$variables) { $variables['#attached']['library'][] = '...
0
votes
0answers
77 views

After an unsuccessful form validation the ajax callback is not found

In hook_form_alter() I added validation handlers using the following code. function calculate_allocation_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'node_work_plan_form') {...
1
vote
1answer
40 views

Error 404 when upload image in profile installation

I am installing a custom distribution, I have created a form: my_distribution.install: /** * Implements hook_install_tasks(). */ function my_distribution_install_tasks(&$install_state) { $...
0
votes
1answer
40 views

Add mini pager and infinite scroll to a view

I have a view where at first 1 item has to show. On click of 'load more' next item has to show and so on. For this i have installed 'infinite scroll module' in drupal 8. Now after showing four items, '...