Questions tagged [ajax]
Use it for questions about JavaScript/PHP code to create asynchronous web applications.
2,483
questions
-2
votes
0
answers
20
views
how to use a different twig template depending on the breakpoint
How to have a way to use different twig templates depending on the viewport , or having a twig variables that give the info ?
An example was using foundation sticky classes on twigh templates.
The ...
1
vote
1
answer
78
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(...
0
votes
1
answer
31
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 ...
0
votes
0
answers
17
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
25
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
39
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' =&...
-2
votes
0
answers
27
views
How to have js retrieve array data from a module controller
My experience with Drupal and Ajax has been limited to the context of a form. In this case, there is no form involved, so also no pre-process.
I am using FullCalendar. My desired flow is this:
Prior ...
0
votes
1
answer
59
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
26
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 ...
0
votes
0
answers
33
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 ...
0
votes
1
answer
45
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
72
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 ...
0
votes
1
answer
17
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
21
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
44
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 {
...
1
vote
0
answers
55
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 ...
0
votes
0
answers
22
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
15
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
42
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 ...
0
votes
1
answer
38
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; ...
0
votes
0
answers
32
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 ...
0
votes
0
answers
14
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 ...
2
votes
1
answer
36
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
votes
1
answer
31
views
Set the quantity per product equal to value in input
I'm using the Commerce Ajax Add to Cart module to add a product to my cart using AJAX. I guess I'll have to do that by creating a patch.
It's working fine, but I'd like to change how a product is ...
1
vote
0
answers
27
views
How to reload flagging form via ajax?
My task is to ajaxify complex flag form (with additional fields).
I need this because the default ajax flag does not dupport fiedls.
I need to have the flagging form for create flag and then update it ...
0
votes
1
answer
26
views
Node form ajax dependent dropdown fields issue
I am using Drupal 9. I know how to change single dropdown list using another one. Here is my scenario:
I have three dropdowns, in node form - company, protocol and investigator. What I like to do, ...
0
votes
0
answers
90
views
How do I prevent a block from being loaded via Big Pipe
I have a view block, nothing crazy, just a couple fields. I want to present it as a carousel. Everything worked fine, until suddenly Drupal decided to start loading the block asynchronously with Big ...
0
votes
0
answers
37
views
Nested views ajax pagination
I am using Drupal 9 and views_field_view to embed a "child" view within a "parent" view. Because there are multiple rows in the parent view, I end up with multiple of the same &...
0
votes
1
answer
73
views
Dynamic Registration Form submission using vanilla Javascript ajax
I want to use the ajax capability of not refreshing the page or rerouting the user to the registration page. Login / Register dialogue modals have been created. I have the login javascript ajax ...
1
vote
1
answer
18
views
Entity reference auto complete field is missing value on ajax callback
I have an entity reference field on my content type using the autocomplete widget.
I'm adding an ajax callback to that field using this in a form alter:
$form['field_er']['widget'][0]['target_id']['#...
1
vote
0
answers
64
views
How to filter autocomplete on a dependent field?
Goal - How to filter autocomplete based on a related field? In this domain, an organisation is selected and then the autocomplete should only allow items created by that organisation to be selected.
...
0
votes
0
answers
26
views
Load view form with ajax missing ajax functionality
When clicking an element I get a form which is generated by a view (using https://www.drupal.org/project/editablefields module). The problem is that the ajax functionality of the form is lost (no ajax-...
0
votes
0
answers
27
views
Run php code on text field in variation possible?
Is it possible - anyone know how - to run php code on a commerce 2 variations created field to check the data in that field maybe using Ajax to make the field typingsensitive in the checkout?? I ...
0
votes
0
answers
36
views
Update body field from ajax callback
I need to update the common "body" field when I change some paragraph fields value.
Here is my hook_form_alter :
$form["body"]["#prefix"] = "<div id='...
0
votes
0
answers
30
views
Need help with AJAX calls within Drupal.behaviors
I'm having some issues getting the following code to work correctly:
(function($) {
'use strict';
Drupal.behaviors.mybehavior = {
attach: function(context, settings) {
// Click on a ...
0
votes
1
answer
197
views
Use ajax to save modal / dialog form instead of page reload
I'm looking for a way to save modal & dialog forms through ajax instead of redirecting the user after the form submit. Ajax is quite unknown territory to me.
I've found several interesting topics ...
0
votes
0
answers
20
views
Can I bind ajax to form or document?
I would like to bind an update to entity browser select.
It is a standard ajax form response. Update the default value of another field.
If I apply the ajax to the inline entity browser form field it ...
0
votes
0
answers
23
views
Ajax message after node save
I am trying to add a Ajax Alert or popup message inside a hook_node_presave or hook_node_update, but it is not working.
My current code look like this, but I have tried a lot of other ajax
$response = ...
0
votes
0
answers
30
views
Controlling dropdown field visibility using #states API for dependent dropdown
I have the following setup.
dropdown_one
[
'#type' => 'select',
'#title' => $this->t('Dropdown one'),
'#options' => $dropdownOneOptions,
'#empty_option' => '---',
'#...
0
votes
1
answer
49
views
entity_form how to programmatically add references and update the form visually (entity_browser)
I´m having an fieldable entity with a reference field to paragraphs field_paragraphs and a paragraph_type with a reference field to content_type event field_events.
What i am trying in the entity form ...
0
votes
0
answers
34
views
Is there any way to add JS to form only when loaded using ajax-api in modal?
I have one page on which there is a button.
On click of that button I am opening a webform in modal popup (Ajax dialog).
What I need is to add a GA script to the form.
I have tried using ...
0
votes
1
answer
271
views
How to configure a custom POST api to accept a request with Content-Type as "application/x-www-form-urlencoded" in the header?
I created a controller in a custom module that accepts a POST request.
I have a setup such that I get a POST request from a third-party application server to this API. But the POST request has a ...
-2
votes
1
answer
133
views
How to open a form in modal from controller while redirect
I can open a form in modal when click on a link (and there are lot of examples in the net as well).
What I like to do:
When some one go to a url in browser or redirect to a url, it will open a dialog/...
-1
votes
2
answers
48
views
How do I add ajax callback to a form element which is created in a foreach loop
Please see the following code:
foreach ($formaddresses as $key => $val) {
// Add edit buttons to custom client-side created addresses.
if (!isset($val['accountnumber'])) {
$form['orderinfo']...
0
votes
0
answers
28
views
How to see if ajax has been added to a simple node form?
This very simple #ajax customisation to a node form is not working. How can I tell whether the callback has been added? I want to calculate a field if the first field is changed.
function ...
0
votes
1
answer
50
views
How disable submit button after call OpenModalDialogCommand in Ajax callback?
I have a block that has a button, when pressing that button an ajax is triggered that shows a popup with the OpenModalDialogCommand event, after closing the popup I want to deactivate the submit ...
0
votes
0
answers
106
views
Ajax form ReplaceCommand functionality breaks after first fire
I Have a form on a page which updates a single field of a Node. The form uses ajax to update the field and returns the newly saved entity and replaces the current HTML so the new field is showing up ...
1
vote
0
answers
71
views
Refresh view using ajax with parameters
I use this code to refresh a view, but It reloads the view ignoring neither page number nor filters.
$('.view-id-name').trigger('RefreshView');
How could I pass parameters (page number, query filters,...
1
vote
0
answers
42
views
AJAX callback is fired only once
I am using hook_form_alter() hook to add an Apply button to the node edit form.. When users click on that button, an AJAX callback replaces the text field value.
It works fine the first time, but the ...
-1
votes
1
answer
31
views
drupal custom callback in node edit form is not firing
i am fairly new to drupal , i have custom button added to one the content type edit page , when i click on that button i want to call a function but it seems like it is not calling function when i ...