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
24 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
108 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
36 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
vote
0answers
90 views

Form alter + Unlimited Values + Entity Reference Field

There are two fields, News Type (Selectbox), News (Reference Entities, Unlimited option, autocomplete) When user select a news type, options of News fields needs to revised. Example: Selecting World ...
0
votes
0answers
18 views

Second ajax select rebuilt by first does not fire

I have a form with 3 select fields. Selecting a value from the first should result in the second becoming populated, and this works. Similarly, when making a selection in the second, the third should ...
0
votes
1answer
97 views

Confirmation message not getting rendered when printing the elements seprately in twig and ajax is enabled

Iam using the following twig code in webform-submission-form--newsletter-signup.html.twig <div class="col-12 col-sm-12 col-md-6"> {{ form....
0
votes
0answers
52 views

How to add pager by ajax Call?

I have a form where you select a year from checkbox and then get all users registered for that year. Since the list can get very long I wanted to use a pager. Initially I just wrote an ajax call on ...
0
votes
0answers
250 views

Update radio button options after AJAX callback

I'm working on a form that submits via an AJAX callback that handles some class-toggling and populates a results table. Here's the callback that each input from the form calls: public function ...
0
votes
1answer
53 views

Change Image Alternative text on select box change

Fields: Image Field - field_image Selectbox Field - field_custom_language Testcase: On selecting a different value from Selectbox, Alternative text of the image field should be changed. Issue: ...
0
votes
1answer
189 views

Need a current page's "Content Type" passed to a node.html.twig template (for a different content type) on page load, AND after ajax call

I'm trying to get the Content Type value of a node page (that the user is currently visiting - let's call it CT-1)... and feed that value as a variable into a DIFFERENT content type's node.html.twig ...
0
votes
0answers
72 views

How do I correctly load a webform using Ajax?

The page I need to make is a bit complex and my team and I face many problems with it. We need to have a page with multiples sections (just square blocs with text on it). Each section displays (on ...
0
votes
1answer
1k views

How to display data without html on ajax call?

How to display only content on ajax hit without html markup? what i am trying to do i have to show data on button click in profile dashboard(custom page) ,for this i have created controller file . ...
0
votes
0answers
34 views

Adding button with Ajax callback in node using preprocess_node

I have my_theme and my_project. Also have a file called my_project.php. There I have two functions and in both of them I have ALMOST the same structure: function my_theme_preprocess_node__foo(&$...
0
votes
1answer
163 views

hook_views_post_execute() don't work on AJAX View with exposed filters after 1st refresh

I have a View which returns 5 entities of the same type. AJAX - enabled, filters and exposed filters, all working fine. I need to add a new result, a user - defined entity, at the top of the View ...
0
votes
1answer
738 views

How can I set form values with Ajax?

I want to set the value of a textfield based upon the selection of a field above. You can choose a template and the textfield would have it as a value. This is the select field used to select the ...
0
votes
1answer
721 views

I want to call ajax callback function from another module's controller in Drupal 8. is it possible?

I am giving the code of my main form and the controller of another module where the ajax callback is written. Actually this ajax callback function will be used in different forms. So I want to create ...
2
votes
1answer
300 views

How to populate an Entity Reference field from a modal AjaxResponse?

I have an entity ref autocomplete field (reference to bundle A) in one of my bundles (bundle B). I want to add a button below this field which will open a modal for a bundle A create form. This code ...
0
votes
0answers
180 views

How do I reload an AJAX modal node add form without altering the behaviour of the original node add form?

I'm trying to edit the behaviour of node submit form (node type = 'class') but only when the form is submitted within an ajax modal window. Importantly, after the form in the modal window is submitted ...
0
votes
1answer
49 views

Why is my Ajax callback not returning anything?

I'm implementing an ajax callback function whats the issue with my code not returning anything. I'm new to backend <?php use Drupal\node\Entity\Node; use Drupal\Core\Form\FormStateInterface; ...
0
votes
1answer
30 views

Returning from ajax callback ruins view

Currently I am hooking into the add to cart form on my website. I added ajax to the edit quantity buttons like : $form_quantity[$key]['#ajax'] = [ 'callback' => 'update_cart_order', ...
1
vote
1answer
110 views

Ajax Multiple Callbacks is not working for first callback?

I have been trying to load the data to other select list field from the first select list callback. I want to change the two select list variables based on the first select list on changes, please ...
0
votes
0answers
28 views

managed_file FormElement submitting form upon file upload

How do i prevent managed_file(Browse Button) from calling submitForm function upon uploading file? I've added '#attributes' => [ 'submit' => FALSE, 'onclick' => 'return false' ] to no ...
-2
votes
1answer
163 views

CSS not work after applying ajax

I have a problem with css after applying ajax. I have an exposed form that I stylized. Before applying ajax it is: id="edit-field-price-value-min" After applying it changed to id="edit-field-price-...
0
votes
1answer
247 views

Creating ajax modal from event

Here's the deal. I want to create a modal popup when an add to cart event is triggered. I've got the event working just fine but can't seem to get the ajax to work properly. What I'm working off of ...
0
votes
0answers
33 views

multiple dependent drop down [duplicate]

In drupal 8, I need to create 4 dependent dropdowns to select item from a huge list. i have no problem creating 2 of them and they work fine with the "ajax" form settings but as soon as I add the 3th ...
-2
votes
1answer
300 views

How to use ajax in entity reference custom form to display no entity error in drupal 8?

I created a custom form on entity autocomplete called items like below, $form['items'] = array( '#title' => $this->t('Items'), '#type' => 'entity_autocomplete', '#target_type' => ...
0
votes
1answer
223 views

Drupal 7 Form API - AJAX updates for multiple file uploads

I have a Drupal 7 custom module form that uploads then processes multiple images. I have an ajax callback that updates page content with the processed images. BUT, the page update happens when all ...
1
vote
2answers
1k views

How do I generate options based on Ajax callback

In Drupal 8, I want to generate options of second select-box based on Ajax call of first select-box. The result generate a third new select box but I don't need to generate a new one. I want to ...
1
vote
1answer
120 views

Add a class to an element after AJAX

I have a view of nodes with an AJAX on scroll set up. Everytime a person scrolls down the page new elements inside a view show up (e.g. nodes). I'm trying to add a new class only to new nodes that ...
0
votes
1answer
85 views

Handling data from form in modal dialog

I'm building a tool that contains a few clickable regions. Each region has a link with class="use-ajax" data-dialog-type="modal" pointing at a custom form route. Everything is working great and I'm ...
3
votes
2answers
403 views

Using #states in a form with checkboxes

I would like when a client check one of the checkboxes, a text field appeares. Example: if he clicks on 3 checkboxes, all the textfields of the 3 show off. My #checkboxes : $form['input']['...
0
votes
1answer
315 views

How to save entity from a ajax form

I'm running Drupal 8.8.x The Problem Entity is not being saved when form is submitted through AJAX. Example: Build Form public function buildForm(array $form, FormStateInterface $form_state, ...
0
votes
1answer
68 views

Updating entities/posting data via ajax?

I've got a handful of entities that need to updated on user interaction, such as: Tracking user progress through a video, such that a listener checks playhead position every x seconds and posts ...
0
votes
1answer
153 views

How to make a text field box appear after clicking select option by using ajax?

I have created a content type and with a field which is a select type and the options is: Text Text area File Now, when I select text area option, then a text area box have to appear below the ...
0
votes
1answer
65 views

How do I dynamically populate a select field?

this question comes quite often but I couldn't make it work to that point. My problem is simple, I have a 2 level taxonomy, I have 2 select fields, one is populated with the parent taxonomy and the ...
0
votes
1answer
1k views

drupalSettings value is undefined [duplicate]

I am trying to call a JavaScript function when I click on a button in a form. I have multiple buttons in a for loop and I have attached the library to all those buttons. (Not sure whether this is a ...
0
votes
1answer
566 views

Ajax callback is not working on views exposed filters

I am implementing dependent filters in views exposed filter for content:datasource search(Solr search). I have a requirement that in exposed dropdown field when a category is selected, by ajax i need ...
1
vote
0answers
311 views

Ajax call in form alter of inline entity form

Inline entity form is using in bricks. In that Inline entity form, there is 2 dropdown fields available . i want to form alter in that Inline entity form, so that selection of one dropdown value, ...
0
votes
0answers
263 views

Strange AJAX HTTP error, 302 redirect error after update and migration

I have a Drupal 7 site (ver 7.67) running on CloudWays, PHP 7.1, MySQL 5.5. I get the AJAX error "An AJAX HTTP error occurred. HTTP Result Code: 302" The debugging information is limited: "Path: /...
0
votes
1answer
452 views

AJAX form submit error when sending form to twig in hook_preprocess_page

I have a simple AJAX form that I can't submit when the form is passed from module to the template in hook_preprocess_page. The same form works fine if sent from controller, it's just that the layout ...
0
votes
1answer
359 views

Can't update radio button fields after ajax callback

I'm having troubles with a FORM in Drupal 8, the idea is: Chose a radio value from radio-estaciones to recharge radio-contaminantes, but, after the callback, the result I see is empty, but in replace ...
0
votes
3answers
86 views

Ajax not working in text field

I made custom module that implements hook_form_alter that marks the field_text_field_1 textfield as Ajax-enabled. When a key is pressed inside the field_text_field_1, it should change the value in a ...
0
votes
1answer
71 views

Drupal Leaflet View loading view block through Ajax

I created a view block for displaying geocodeed nodes on a View Leaflet map. Everything working, the map displays the markers as I want. Now, I would like to load this map throught drupal ajax I ...
1
vote
1answer
497 views

Change views exposed filter value only on page reload [duplicate]

Is there a clean way to alter a View exposed filter field, but only on page reload and not each time you submit the exposed filters form ? Example I have a View with exposed filters. When a user is ...
0
votes
1answer
125 views

How do I add an AJAX action on a select element in a ContentEntityForm to change the value of another select element

I have a ContentEntityForm with two select elements category and data_type. I want to load the options for the second select element when the first select element changes. I have tried to add the ...
1
vote
1answer
635 views

Hide certain field on form alter using AJAX

I have a webform created using interface, and need to hide some fields through button. Using form_alter I have added that button added AJAX call with it. Now I want to remove/hide certain element ...
1
vote
1answer
290 views

entity_autocomplete field thats added by ajax is not working

I have a field im adding to a node-edit form by ajax. the field is a simple taxonomy auto-complete field. when I add it directly in my form_alter it works, but when it's added by ajax, The ...
3
votes
1answer
744 views

How to load a view via ajax without breaking ajax functionality?

What ist the correct way to load a View via Ajax and not breaking the view ajax functionality like the pager? I tried it this way: In a template: <a href="/example-module/15?token=...
1
vote
0answers
124 views

How to achieve dependent filters programmatically for views exposed form?

I have a requirement like Category and Sub-category should display as dependent filters. When I choose a Category next related sub-categories should show up in another field. These mapping is done in ...
0
votes
0answers
105 views

Ajax call for autocomplete reference field

I do not succeed to fire the ajax when an autocomplete reference field widget is populated or changed inside a paragraph form. TO BE MORE CLEAR: I Succeed when using a simple select list but not when ...

1 2 3
4
5
50