Questions tagged [ajax]

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

Filter by
Sorted by
Tagged with
-2
votes
1answer
25 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' => ...
-1
votes
0answers
17 views

Get user logged information in an Angular application

I need to develop an Angular application within Drupal 8. I'm trying to get the Drupal logged-in user from Angular. Users log in Drupal after different checks (login, pass, SMS PIN), so I don't want ...
0
votes
1answer
40 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
25 views

Drupal 8: how to 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 ...
0
votes
0answers
34 views

How to inject a service into a callback in ajax form? [closed]

I can't access to my injected service from inside a form #ajax callback method : this is the form element that triggers the #ajax callback ( which is an external class method): /src/Form/...
1
vote
1answer
25 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
0answers
24 views

jQuery click event only fires once for each element

I'm attempting to use a little bit of jQuery to perform a views reload when a certain flag is clicked. Updated Problem: The updated code below now works, but requires a timeout. Is there a way of ...
0
votes
1answer
26 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 ...
0
votes
0answers
19 views

Dialog modal stops working when updating a block (panel pane, mini-panel, Views. etc) with ajax

I've been using Dialog for a while now, and this is an example of my standard way of requesting a form to be rendered in Dialog popup: $class = array(); $attributes = array(); ...
1
vote
2answers
37 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
33 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
0answers
20 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
43 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
0answers
15 views

How to add effects to Ajax response commands

I have a view with exposed filters which are ajax enabled. I also have a basic module set up with an event subscriber which picks out ajax responses from the particular view, based on this tutorial. ...
-1
votes
0answers
58 views

empty_option value after form submission (field 'select'; field value depends on other selection)

I'm trying to save form data to the database. The form consists of two fields (select). The values of the second one are dependent on the values of the first (ajax callback). I also added #...
0
votes
0answers
21 views

Sharing permission in controller and block

I have a custom block on and entity page that displays buttons that when clicked send an AJAX request to a custom controller. A button in the custom block is displayed if a certain condition is met (...
0
votes
0answers
16 views

Dynamic field by ajax callback is not added to form [duplicate]

I have a form where I create a new field when an input field has been filled out. I do this with ajax callback that seems to work partly. The field is being rendered but it doesn't get all the ...
0
votes
1answer
27 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
0answers
15 views

Change the form value and submit the form in a single ajax call

I have two select fields in the form. The values of the second select field depend on the first one. When I change the first select field, I need to change the options of the second select field and ...
0
votes
1answer
39 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
0answers
11 views

Radiobuttons on a custom entity form do not get set once ajax is bound to the radio button

I am trying to trigger a change of a select box options on the change of a set of radio buttons in an entity form. The only event I am able to get the ajax event to run is the click event as I am not ...
0
votes
1answer
25 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 ...
0
votes
0answers
18 views

How to refresh a view after a webform is submitted

I have a webform placed in a block below the webform block I have a view that displays the content now I want to refresh this view after the webform is submitted. The webform is ajax enabled and so is ...
0
votes
0answers
30 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
16 views

Lost name attribute after recharge select field with ajax callback [duplicate]

I have a great trouble with ajax callback, I need to recharge a select field, the callback goes right, but, the returned field in ajax request goes without name attribute, so, I lost it while submit ...
0
votes
0answers
48 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
79 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
34 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
41 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
22 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 ...
0
votes
0answers
14 views

Search by title or SKU

Im having a problem when I try to search by SKU or whatever Im new in drupal Drupal core 7.67 | Drupal commerce 7.x-1.15. It does not allow me to finish the string and it delete some strings before I ...
1
vote
1answer
31 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
34 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 ...
0
votes
1answer
53 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
63 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 ...
0
votes
0answers
16 views

How can I display custom error message using ajax submission?

I use the following code to submit form data using ajax: <?php namespace Drupal\ajax_form_submit\Form; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\...
1
vote
0answers
64 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=...
0
votes
0answers
34 views

Tableselect with return new response doesn't work

I'm newbie in drupal and I want to create contact list with dynamic search on ajax. I want to ajax load my tableselect. So I use return new Response(render($form)); where the form is tableselect. I ...
0
votes
0answers
14 views

Keep open state of a block when the page is reloaded

in a search_api view I have several facets links. These links are placed inside several block. If I open a facets block (collapse block), and I click on a facet link the page is reloaded...and the ...
1
vote
0answers
17 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
81 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 ...
0
votes
0answers
12 views

Paginated ajax form with non-sql data

Using Drupal 8 I created a form to load data from a webservice with ajax below the form. Now i'm trying to add pagination to result, but the paginator is not been loaded, i'm doing something wrong?. I'...
0
votes
0answers
24 views

Pass rendered markup to redirect route

Drupal 8.7.x I have form that passes the outputted data into a template. This template with the data gets rendered into a string like so: : public function submitForm(array &$form, ...
0
votes
2answers
119 views

How can I display a message when “add another item” on an Inline Entity Form Multiple field is clicked?

In Drupal 8 inline entity form is there a "form_alter" or "submit handler" or some type of ajax callback for when a user clicks "add another item"? What I would like to do is display a message to the ...
0
votes
2answers
88 views

Paginated form with ajax checkboxes throws “The specified #ajax callback is empty or not callable”

Using Drupal 8.7.7 I have a form which consists of a paginated table of users. Each user row has a checkbox element in the form with an ajax event attached. This is essentially to allow me to store ...
0
votes
1answer
38 views

Create nodes unlimited times

I've been trying to ajaxify the node creation form, the purpose? Save the node and remains in the node creation page (Done) If the user clicks the save button again save a new node The second point ...
0
votes
1answer
64 views

AJAX form doesn't use ajax until cache clear

I'm defining an ajax form in my custom module (#ajax for submit). It is shown in custom block. But it works fine only on cache clear (on Drupal clear all caches or on ctrl+r in chrome). If I just use ...
0
votes
0answers
24 views

Dynamically created elements trigger wrong submit handler post AJAX event

I've found that dynamically created submit handles will adopt the first declared submit function in a form after an AJAX event has been processed. Demo code: <?php function form_test_main_form($...
0
votes
0answers
28 views

How to attach behaviors after an AJAX load in a view

I am trying to add a reset button to some exposed filters for my view. My code: (function ($, Drupal) { Drupal.behaviors.blog_filters = { attach: function (context, settings) { var ...
0
votes
1answer
21 views

Embedded View Form Ajax not working

I have a an embedded view display (type = embed) with an exposed form and pager. Ajax is enabled for the display. The pager reloads the display via ajax, however the form does not. I'm all but certain ...