Questions tagged [ajax]

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

Filter by
Sorted by
Tagged with
-1 votes
0 answers
16 views

Adding options to a select via ajax: "An illegal choice has been detected" [duplicate]

Coming from this thread without a solution: Programmatically add values in a select field: issues when submitting I get this error when submitting the form after selecting an option loaded via AJAX: ...
0 votes
0 answers
17 views

Refresh a form with Ajax after closing a Dialog

So I have a custom form in which I display a list of entities. Below that list, I added an “Add More” link which opens a Dialog. When I close (or submit) the Dialog, I want the list of entities to be ...
  • 371
0 votes
0 answers
59 views
+50

Action of webform displayed in modal opened by OpenModalDialogCommand in AjaxResponse

I'm trying to open a webform in a modal by using OpenModalDialogCommand in an AjaxResponse like this. in buildForm method, I'm specifying AJAX callback like this: $form['actions']['submit'] = [ '#...
-3 votes
0 answers
17 views

How can I create form with ajax validation and ajax callback?

I have a problem with the form, it was working as expected before, but we want to add css styling, when some required elements aren't filled and it makes the form add this css from ajaxCallback ...
-2 votes
0 answers
18 views

Ajax error 200 All over the site [closed]

I have a Drupal site I haven't maintained for a while. All in a sudden, it started giving AJAX errors on every actions I make. I know I should probably update the site, but I'm not sure I can do it ...
-1 votes
0 answers
32 views

Why do VERF filters reload the View page when a certain value is selected?

I have a View, Use Ajax is checked in the settings. It has 5 exposed filters. VERF filters that are provided using the Views Entity Reference Filter module reload the View page when selecting some ...
0 votes
1 answer
45 views

How to identify ajax request in the exposed form of the View?

I have a View, it is ajax View. There are exposed filters (with checkboxes). When I select a checkbox \Drupal::routeMatch()->getRouteName() shows general route name: views.ajax I need to change ...
0 votes
1 answer
43 views

Ajax validation of file upload in Commerce Product with product attributes

I am building a shop with Drupal Commerce right now. I have a product that uses an Order item type, which supports a file upload. The same product also has some product attributes that load the ...
-1 votes
0 answers
26 views

Ajax form stopped working - triggering_element is null on localhost

I have a custom webform, that worked fine until recently (also on localhost): class ConfirmDeliveryForm extends FormBase { // ... public function buildForm(array $form, FormStateInterface $...
  • 280
0 votes
1 answer
19 views

managed_file not initialised after form ajax

I'm having issues with a managed_form field not beeing initialised after it is introduced via a ajaxcallback in a custom checkout Pane: /** * Provides a custom message pane. * * @...
  • 280
-1 votes
1 answer
49 views

How do I implement an AJAX callback?

Given is a Drupal 9 project. How can I make use of Drupal functionality through an AJAX call? web/modules/custom/mymodule/src/Appointment.php namespace Drupal\mymodule; class Appointment { public ...
-1 votes
1 answer
35 views

How can I avoid fields being disabled on AJAX requests (attribute disabled) in Drupal?

I want to make an input not be disabled when I submit an ajax request. I tried reversed variants in these answers, i.e. hanging an "AjaxStart" on the document. $(document).ajaxStart(function(...
  • 266
0 votes
0 answers
51 views

How to alter form after doBuildForm call during AJAX response

I'm altering a form defined by a contrib module. Recently, that module switched to AJAX and my form alter isn't applied during the AJAX response. I believe the problem is in the following code used by ...
0 votes
0 answers
8 views

Ajax issue in tab when embedding a view

trying to add two views in panel in drupal 7 in one views it is working fine ajax like comment on ajax and all works good , but while switching on different tab ajax is not working fine. in recently-...
1 vote
1 answer
84 views

AjaxCommand to scroll to top of page?

I have created an AJAX form. After the form is submitted, I call $this->createOkResponse() which updates a section of the page with a message (it replaces the form with the message). It all works ...
3 votes
1 answer
93 views

How do I AjaxResponse on a custom AJAX call?

I have some custom Javascripts. at the part of code I want to leverage Drupal AjaxResponse but looks like it's only working when there Triggered by Drupal Form's ajax element. ( my ajax call verb is ...
  • 21.1k
0 votes
0 answers
50 views

Ajax MessageCommand is not using Bootstrap Barrio status-message theme template

I have a Controller in my custom Module which returns an Ajax Response: $response = new AjaxResponse(); $response->addCommand(new MessageCommand('In den Warenkorb gelegt', NULL, ['type' => '...
  • 131
0 votes
1 answer
29 views

Refresh ( or reopen) a Dialog (meida browser) with javascript

I have a media field, which when the user clicks on it, the media selector will open with the list of media. I have a custom button there which do some ajax calls at the end I want to refresh the ...
  • 21.1k
0 votes
0 answers
54 views

Media Library and paragraphs not working

I have a paragraph with multiple fields, one of them is a media field (document type). If I add a new paragraph and then add media I got "ajax error". If I add new paragraph and save content ...
  • 105
0 votes
1 answer
69 views

Drupal.Ajax.prototype.beforeSubmit results in AJAX Error

I have a module that creates an AJAX Form. I need to copy some values from the DOM to a form field when (or before) the form is submitted. In my module JS, I tried this: (function($, Drupal) { ...
0 votes
0 answers
23 views

Using AJAX to Trigger an Event Based on the Value of a Date Feidl

I have a node type in Drupal 9.4 with lots of fields. The node type has some very simple form alaters to add additional instructions to the node add form. I also add a JavaScript file that shows users ...
  • 175
0 votes
0 answers
45 views

Drupal.ajax() vs JQuery/$.ajax() – what is difference?

Official manual says This scenario doesn't seems allow behaviours (to be confirmed) Does it mean that Drupal.ajax() shouldn't be called inside Drupal.behaviors.my_func and/or inside JQuery's $.ajax? ...
  • 1
0 votes
0 answers
51 views

Replace a Custom Block Via Ajax

I have a block on my page that shows summary information for a content entity. In particular, it shows a boolean value on if the user has watched a video or not. I have already implemented that the ...
  • 323
0 votes
0 answers
49 views

Ajax response to wait and retry

Use case I am building a button to generate a pdf. The generation process can take a while. Clicking the button triggers an ajax request which can meet one of 3 scenarios: The pdf was already ...
  • 3,502
0 votes
1 answer
40 views

Multistep Ajax form with ManagedFile: current step array dissapears from $form upon file upload callback

I have a custom multi-step Ajax form. On the second step, I have defined a managed_file field where users can upload several attachments: public function buildForm(array $form, FormStateInterface $...
0 votes
2 answers
31 views

use-ajax class doesn't trigger ajax event

This is part of my code in custom module in src/Plugin/Block/FavoriteBlock.php: $build['ajax_link'] = [ '#type' => 'link', '#title' => $this->npxFavoritesRepository->getTitle($node), ...
  • 201
0 votes
1 answer
42 views

Add an event listener to select list

I've attached the following js to an exposed views form field and it works on first page load but when the form is changed (by ajax) it doesn't fire. I can't quite work out where to add an event ...
0 votes
1 answer
52 views

Multiple ajax form not working on whole site

I have multiple pages which contains multiple ajax forms. When I am working on a particular form, its ajax submission is working. But at that moment, if I go to second page form, ajax submission not ...
0 votes
0 answers
48 views

I lose template suggestions when an ajax event is called

I'm generating theme suggestions based on the formdazzle module, I made my own variant because I needed another level of granularity of theme names and it works fine. Well, in the alter hook I have ...
  • 351
1 vote
1 answer
121 views

AJAX in a plugin form results in "The specified #ajax callback is empty or not callable."

I have a configuration form for a Condition plugin I want to have ajax in. When selecting from this field, I want to get a list of displays for that View: public function buildConfigurationForm(...
  • 26.9k
0 votes
1 answer
125 views

How to refresh and reload (with ajax?) order checkout panes and order calculation independent from commerce cart refresh (e.g. billing address change)

I have following problem: During checkout, my customer has to fill in his billing address (at least at the first time) to calculate VAT rate and gross price. Further calculation is done via an order ...
  • 129
0 votes
0 answers
28 views

How to persist webform validation result in multistep ajax webform handler?

In my AJAX form the user has to do a validation as he needs a code to enter the rest of the form (it has 3 pages or more). I have an handler to validate this and this same handler uses that code to do ...
0 votes
1 answer
61 views

Overriding Drupal.ajax.prototype is not working

I am trying to override Drupal.ajax.prototype.beforeSend like this: (function($) { // In mymodule.js, which appears after ajax.js in the page build Drupal.ajax.prototype.beforeSend = function(...
1 vote
1 answer
49 views

How to add an unique wrapper id to a widget element?

I made a widget that "generates" fields based on the option chosen of a select field. I got most of the logic done: 1- An option is chosen from this field: $element['value'] = [ '#type' =&...
0 votes
1 answer
92 views

Can I add elements to a field widget with AJAX?

I want to add fields depending on the first option selected. I also made a form with a similar behaviour but it wasn't a field widget. I used this module as an example to make the form I'm not sure if ...
1 vote
0 answers
32 views

How to wrap select list in custom html?

I have a select list created by views exposed filters. When I debug the templates used. I have the exposed filter template, then the select list is in a seperate template. I tried just putting my html ...
  • 153
0 votes
0 answers
44 views

AJAX callback not fired in hook_form_alter()

In Drupal 7, customer wants to add a button to the user_profile_form. So in my custom module, I create the button and its companion callback. But while the button appears on the form, I see no ...
  • 441
0 votes
1 answer
57 views

How do I skip calling a custom validation function in a form with AJAX dropdowns?

I am using headless Drupal with .NET middleware. I have a Drupal 9 form. This form contains two drop-down elements which are filled up depending on a value selected in a third drop-down. I have a ...
1 vote
1 answer
306 views

Multiple forms on page

I am trying to get multiple forms to work in a views display. All of the forms uses AJAX, but they appear to be interfering with each other. One form is the Views Bulk Operations form that turns the ...
  • 161
0 votes
1 answer
25 views

Modify cart view to allow direct quantity updates

In want to modify the cart view so that when costumer change quantity of item in cart, it will update cart and total price automatically and immediately through AJAX (instead of when pressing button ...
0 votes
2 answers
35 views

How do I dynamically (AJAX) show radios in form API?

A form like the following is expected to show additional fields when user selected "Yes" in the "Show more" radio button. When shown, the more section has a "Name" text ...
0 votes
1 answer
46 views

Why a form doesn't keep the value created during construction

Here is a form using DI for $this->entity_type_manager There is also a radio-button with Ajax (I have added the code as it is maybe the reason of my problem) class myForm extends FormBase { ...
  • 514
1 vote
0 answers
188 views

Reload commerce_cart_form view

I'm coupling Drupal commerce, DC add to cart ajax and commerce flyout modules. This is my view configuration : On my /cart page, I have the initial form (the view) to change the quantities, delete ...
  • 57
0 votes
0 answers
39 views

Creating link option in form and modifying it's url in form alter hook

I'm searching to modify a node add form, so far i added a personal field "link" to display as a button to add another node type if the user wants to, that link has this code in ...
0 votes
0 answers
27 views

How to add multiple items to the cart in one go - whilst including "order item type" with extra fields - Drupal9

I had this working using multiple AJAX cart submissions in D7 - using AJAX_Cart and https://www.drupal.org/project/commerce_add_to_cart_extras I'm now trying to find an elegant way to achieve the ...
0 votes
1 answer
116 views

How to define where to display form_state->setError when using multiple ajax callbacks?

I am working on some custom functionality inside of a views table view that enables a 'quick edit' form as an available field via views field plugin. The form is rendered to each row separately using ...
  • 161
0 votes
1 answer
86 views

Ajax only binding once

It looks like Drupal changed to a different, non jQuery version of once, and now all of our code that updates the DOM and needs to reattach the events for AJAX elements no longer reattaches them; ...
  • 408
0 votes
0 answers
34 views

Document File Field Ajax Error

I am having trouble with file uploads for anonymous users. I get a non-descript ajax error. It works fine when signed in as an admin user. Any ideas on how to troubleshoot the problem? I've made ...
  • 1
0 votes
0 answers
15 views

Change ajax effect on form

i am making a multistep form, and I would have liked the transition between the steps to be done by sliding from right to left. The Drupal API offers "fade" and "slide", but the ...
  • 121
3 votes
1 answer
59 views

Custom AJAX Response not firing on Flag action

I'm trying to run custom javascript functions at the same time as people interact with certain flags on my site, I have followed this tutorial on how to respond to both Flag/Unflag actions, and this ...

1
2 3 4 5
51