Questions tagged [ajax]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
21 views

Custom form calls different form in modal, submit/ajax callback of second form not called

I created 2 forms: dms_gift_voucher/src/Form/GiftVoucherForm.php ... /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { .... $...
0
votes
0answers
18 views

Getting intermittent AJAX.js error on a Commerce site when changing product variation dropdown menu

We've been trying to troubleshoot this issue for weeks now without luck and am really hoping someone here can help point us in the right direction. We have a D8/Commerce 2 site with a **very ...
0
votes
1answer
37 views

Populating Select2 with AJAX

I am trying to populate a selec2 field on open with AJAX in Drupal 8. In my hook_form_alter, I have added the following code: $form['#prefix'] = '<div id="form-ajax-wrapper">'; $...
0
votes
0answers
11 views

How to recenter a geolocation google common map in views after an ajax boundary filter execution?

On Drupal 8.97 with all updated modules, I have a View that uses a Geolocation Google Common Map as an attachment. The map acts a boundary filter, but after the filter executes Drupal.ajax(...
-1
votes
0answers
22 views

Intermittent AJAX error on Commerce Product pages causing pricing not to update when variations are changed

We have a Commerce 2 website with an intermittent where changing the variations on the add to cart form does not update the photos and prices. When the issue is occurring there is an AJAX error in the ...
2
votes
1answer
67 views

Ajax submission not working for Webform within a node

I am working with a feature where a newsletter subscription form (Webform with ajax submission and confirmation type is inline) should appear in a node. The node would be showing as a popup and the ...
1
vote
1answer
42 views

Show node links in modal buttonpane

I want to show some node fields in buttonpane when I open node in modal. As far as I know, it will automatically show there inputs with type submit and links with class button, but I added class ...
2
votes
2answers
57 views

Changing 2 Elements on Ajax Callback

I have an element $form['elements']['manufacturer']. On change, I want to change $form['elements']['form_factor'] and $form['elements']['model']. Currently I have: $form['elements']['manufacturer']['#...
1
vote
0answers
56 views

CKeditor Media Edit: AJAX HTTP error 500 [closed]

How can I fix the AJAX HTTP error 500 to make the "Edit media" button in the body of the CKeditor work? I am trying to use the "Edit media" function to edit an image, which was ...
5
votes
1answer
144 views

Error handling with Drupal.ajax()

First I am not very good in JavaScript so maybe I do not know some very basics... I apologize in advance. I created a form where I want to save every change in single fields directly without the need ...
0
votes
1answer
15 views

Ajax callback on Views exposed form filter

I'm trying to add an #ajax callback method to my views exposed form filter select box. But it seems the form have some issues with the callback. My code is pretty simple /** * Implements ...
2
votes
1answer
74 views

How to attach variables to drupalSettings with ajax?

With the page attachments function, I can easily attach a library or some variables to drupalSettings. Now however, I want to replace some HTML code with ajax AND attach some variables to ...
0
votes
0answers
32 views

Load more AJAX with entity query

I want to set load more functionality using entity query, i have load all user data using entity query and set range condition and sorting condition, my scenario is i want to load all the data in ...
0
votes
2answers
72 views

Sending data to a controller with AJAX POST

I am using AJAX to send request to controller, but the data is sent with the GET method. I want the request send with the POST method. The following is the code I used. var table_url = '/table-data'+...
0
votes
0answers
33 views

How to use ajax without a form? [duplicate]

I'm trying to setup a ajax call with JS but without building a drupal form. Basically it will trigger when the user clicks a specific class element on the page. I've looked through the documentation ...
4
votes
1answer
130 views

How do I render a form in a div through a javascript call

I'm trying to load a form into a div using a javascript call. I can get the form in the div, but nothing works (autocomplete fields, wysiwyg fields, custom submit handler). I know I must be missing ...
2
votes
1answer
54 views

Open ajax dialog with JavaScript

By adding use-ajax to a link we can open a modal using the Drupal ajax library as per the docs. E.g. <a class="use-ajax" data-dialog-options="{&quot;width&quot;:400}&...
0
votes
0answers
38 views

Change $form attribute in a callback

I have a form and a field model. In a hook alter, I add ajax callback to a function getMobileorFixed that does some taxonomy computation. Here is the hook_alter function THEME_form_FORM_ID_alter(&$...
0
votes
1answer
40 views

Cogwheel / Gear button does not work on manage display pages on Drupal 8

I am new to Drupal and having some issues with the cogwheel button on all of content types when I want to manage their display. When I click the gear / cogwheel icon "please wait" message ...
0
votes
0answers
16 views

Pass field value without form update

i am got some trouble with AJAX in Drupal 8 Form API.I use few fields with #states so that the value of one field depends on another.And in the end of form i need to pass field value to another field....
0
votes
1answer
17 views

Have a child node inherit taxonomy from a parent during /node/add?

In Drupal 7, I have two content types: Parent Events with tags (like "outdoors" or "popular" or "suitable for kids"). "Tags" are taxonomy terms in a vocabulary,...
0
votes
0answers
7 views

View: update single rows with AJAX on a VBO view?

We use a view to list all new entities, let's say "message entities". Users can create messages, those messages are created as a custom entity type and get listed in an inbox as long they ...
1
vote
0answers
29 views

Close a content type form in a modal popup and avoid redirection to the created node page

I have a content type reference on a user page. On clicking the add content button it opens as modal popup with the node form. Post filling the form on submission the page redirects and goes to the ...
2
votes
0answers
30 views

Return and display the same form in Ajax Response

Summary: I have an AJAX form. When I press the submit button, I want to build the same form, and return it for display again. It's working fine if I display another form, but not with the same form. ...
0
votes
0answers
19 views

How to implement Ajax on views form

In a view such as what you find at /admin/content The is a form on the view to delete, publish etc. Is it possible to Ajaxify so that the form will submit and the view will refresh.
0
votes
1answer
110 views

Debugging Ajax Callback

Goal: Print/dump $formState values to debug I am altering a form and the functionality works: $form['elements']['location']['deparment']['#ajax'] = [ 'callback' => 'myAjaxCallback', 'event' =&...
0
votes
1answer
28 views

How to create content / entity via ajax on a view?

I have a view listing some content and I want to have an "Add new" button, which should load the node form via ajax (either modal or into a div). After I save the form, it should still stay ...
0
votes
0answers
34 views

Replace the default modal with a different one

I want to replace Drupal 8 default modal with MDB. How I can do it? Should I unload default library for modals and load new one? Any idea?
0
votes
0answers
28 views

Ajax callback issue

I am using ajax callback on field_status. This is a drop down menu. A selection in field_status should trigger comment fill-up. I am getting blank comment box. function helper_form_alter(&$form, \...
0
votes
1answer
220 views

Ajax error when trying to add another paragraph

Drupal 8.9 and paragraph 8.x-1.11 My issue is that Ajax breaks when altering the #validate form. This is an issue for any form! It may have to do with my ajax, but here is my setup. I have a paragraph ...
0
votes
0answers
14 views

How to update value of single field of same node using node_save?

The problem statement: I have one content type called 'Employee' which has 10 nodes. I have to perform the voting for each node. I am saving the vote count in the field called 'vote count'. But when ...
0
votes
1answer
19 views

How to access backbone model from custom javascript outside of view

I was wondering if there is a way to access backbone model variable outside the scope of the backbone model/view.This is the backbone model: function (Backbone, Drupal) { Drupal.addToCart....
0
votes
0answers
15 views

Add AJAX to view reference field (UPDATE)

i have a custom block with two field viewsreference(field_lg_cb_lista) and field view_mode(field_lg_modo_de_vista ). i want to update the field view_mode to display only the view modes aviable for the ...
0
votes
0answers
19 views

Saving JSON to user field

I have a user field that'll be used to save some user-specific JSON. I have ajax that uses a token with a route to get to a controller to save some JSON to the field. I basically have this: public ...
0
votes
1answer
17 views

Form textfield AJAX validation “deletes” injected services to form

I'm trying to create a form that has two services injected (for access to an API) and a textfield with an AJAX callback. Here it is: public function buildForm(array $form, FormStateInterface $...
0
votes
0answers
13 views

Form #states API by content type

I have a content type A. In this content type, i have paragraph (between 0 to n) with 2 fields. First field is content type select (A, B and C). Second field is based on the first field, only need to ...
1
vote
0answers
50 views

How to validate a modal form?

I have a custom module which adds a button to a node form. The button opens another node form in a modal and when submitted, it takes the entity created in the modal and fills in an entity ref field ...
1
vote
1answer
33 views

hook_form_alter() Ajax suffix replace

I'm trying to rewrite a form item's suffix on an AJAX callback and it keeps prepending the first choice and then doing nothing else. My code: function my_dashboard_form_alter(&$form, \Drupal\Core\...
2
votes
0answers
29 views

Different 'Items Per Page' on different pagination while using 'views_infinite_scroll' module

I am using views_infinite_scroll module to load more nodes with 10 nodes on every click and views AJAX is enabled. I am working on a requirement like as, I have 100 total nodes and getting in a view ...
2
votes
0answers
67 views

Validate a form multiple times

Is it normal that my validateForm method in Form API doesn't trigger second time i call it? And if yes, how do i trigger it multiple times? I've got multistep form and i want to validate each step ...
0
votes
0answers
24 views

Alter Address field in order to add a list of cities

I need to alter the address field because I want to transform the locality textfield in a nested select box along with administrative_area value. I've tried to do that with a hook widget_alter, form ...
0
votes
0answers
27 views

How to show inline error messages when submitting webform using AJAX

I have a drupal7 setup. I have a webform, which I am submitting using ajax. I have implemented a nice solution given over here. Everything works fine including validation and after submission messages....
0
votes
1answer
33 views

How to use ajax callback on auto complete field inside a block settings form?

public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $selected = 'value of a field'; $form['node'] = [ '#type' => '...
0
votes
1answer
32 views

Ajax callback never called / triggered

I'm working on a payment gateway, so I've created a BasePaymentOffsiteForm form where I'm trying to make an ajax callback, but it is not working. Can you help me to know what is wrong with my code? ...
0
votes
0answers
33 views

Ajax callback values not found with upload managed_file field

I have a custom module in drupal 8 that has a few sections that utilize Ajax updates. I also have a "managed_file" field (Form API). The ajax works fine and updates two dependent fields, but the ...
0
votes
0answers
22 views

Ajax callback values not found when the form is submitted

I have a custom form. "instrument_dropdown" fields populate via ajax after selection of "instrument_family_dropdown" select field. It works fine if i does not add upload field. When i add upload file ...
0
votes
1answer
31 views

Is filtering using images possible?

Novice here. I'm on Drupal 7. I have a content type with a title, image and body field. I've created two views to display that content. The two views are on a page and I need help connecting them so ...
0
votes
0answers
22 views

Is there any native way to implement AJAX form submission without a button?

I need to implement a form that automatically saves data on each element change. So I can add a button with ajax callback and trigger mousedown on this button on "change" event using jQuery. And ...
0
votes
0answers
40 views

WidgetBase with Ajax Callback and manipulate #tree values

After many tries, maybe someone can help me here. I want a dynamic form field in a widget base, but I keep having problems. 1st Values of the submit button are lost after submit and can´t manipulate ...
2
votes
1answer
23 views

Setting value of form element from $form_state not working

I need to track previous values of a few form elements on a form to detect when they change to invalidate some other options on the page. Essentially, if the value of these fields change a field that ...

1
2 3 4 5
49