Ajax is a group of interrelated web development techniques used on the client-side to create asynchronous web applications.

learn more… | top users | synonyms

1
vote
1answer
33 views

Fill form on ajax callback

Seems to be an extremely simple question. But I can't figure it out. In my module's form I need to load form values depend on the value of certain one and rebuild the form using those. here is the ...
1
vote
2answers
28 views

Add form field with AJAX

Here is the form: function payment_form($form, &$form_state) { $form['#tree'] = TRUE; // since credit card is also an option, the gift card section is contained in this div. $form['payment'...
1
vote
0answers
14 views

single exposed filter for two displays in same view

I have three displays in same view. Every display has exposed form filter and in every pages ajax was set yes. How to use a single exposed filter for these three displays in same view? I placed these ...
0
votes
0answers
12 views

Form ajax add more button added via another ajax callback not working

I have a form button which I want to add another field with another button on that form( I am able to do this) but second button is not clickable. Any idea. Following is my code- This is my form code-...
3
votes
1answer
38 views

Modal form instead of redirect

I have a site-wide contact form setup that redirects the user to the homepage and posts the submission result to the help section. It works as intended, but I was wondering what I would need to do to ...
1
vote
2answers
30 views

Get content of selected option after user select any option from select field

I have created a content type, This content type form having a select box. I need to develop a functionality like once the user select any option from select field the following textbox should having ...
0
votes
0answers
24 views

The module “JS” does not work with a determined bootstrap level ('bootstrap' => …) [duplicate]

https://www.drupal.org/project/js It only works without setting a bootsrap level or with 'bootstrap' => DRUPAL_BOOTSTRAP_FULL. When I set 'bootstrap' => DRUPAL_BOOTSTRAP_SESSION (for example) it ...
0
votes
1answer
25 views

After any AJAX form event, all Entity Reference Fields are blank

After any AJAX event in the form (Upload image, add a new field collection row etc.) All Entity Reference fields go blank. I have multiple entity reference fields, all using a view to get list ...
0
votes
0answers
21 views

Is it possible to invoke API functions inside a JS callback?

I used js module. I wonder about calling the following functions in a callback: node_load() entity_load() user_load() I encountered a website error using such functions. Something became wrong in ...
0
votes
0answers
8 views

Panels Ajax Tabs - Why won't ajax work after first click? + Patch Application

Using Panels Ajax Tabs to display four views through Panels. Originally, I was using Panels Tabs to display the content, but ran into compatibility issues with jQuery (known bug of Panels Tabs, but ...
0
votes
1answer
10 views

How to pass along current $form_state for an #upload_validators callback?

I have a managed_file #upload_validators callback and when it is called the $form_state does not get passed along with it. My goal is to use another field in the form to rename the uploaded file. I ...
0
votes
0answers
15 views

Views ajax took long time to respond on first search, and loads normal for next searches

I am using views exposed filter to render list of branches for a particular city or zip code. After clearing cache when I search for any city it tooks around 15 - 20 Sec's to render a view, with the ...
1
vote
0answers
47 views

Use a custom JS modal to confirm changes made on node add/edit form before submit

I basically want to do what confirm_form does, but in a custom modal (I am gonna use a JS plugin to generate the confirm modal). So what I have is a large hook_form_alter, and I am using the ...
0
votes
0answers
16 views

Add new submit handler to Ubercart ajax “add to cart” form

I am using Ubercart ajax driven "adding products to cart" functionality and I'd like to add my own submit handler to the event of adding product to cart. I have tried: function activit_form_alter(&...
1
vote
0answers
16 views

RefreshView, can't select html refreshed elements

I have a view page. This page has 3 blocks. Block 1 refresh Block 2. Block 2 refresh Block 3. My code is as follow : (function($) { Drupal.behaviors.mymodule = { attach: function(context, ...
1
vote
1answer
16 views

How to prevent closing CTools modal window with ESC during AJAX?

How can I prevent closing CTools modal window with ESC key during AJAX request?
0
votes
0answers
8 views

How to save Webform's component fields using field specific AJAX buttons?

How to add a save or save draft button under each Webform's component field to save the edited value for that particular field? Any idea how to do that?
0
votes
0answers
21 views

how do i set original value after $form_state->setRebuild(TRUE);

i have form, with dynamic fields that can be added and removed from button using ajax submit/callbacks. the problem that i encounter is: every-time i add new field, the 'add button' will submit with ...
2
votes
1answer
22 views

I don't want ajax submit / callback validate form '#required' => TRUE,

I have form with static fields and dynamic fields as follow: fieldset textfield00 (require = true) textfield01 (require = true) fieldset textfield02 fieldset add textfield submit button ...
1
vote
1answer
46 views

How do I pass JavaScript variables back to PHP?

I'm trying to build a Drupal 8 module with a jQuery plugin. I wanted to pass some of the JavaScript variables to PHP so that I can save the variables into database. This question asked about the way ...
0
votes
1answer
28 views

Form selection with radios, ajax and taxonomy terms

In my form i get the message: "An illegal choice has been detected. Please contact the site administrator." after i didn't select a radio box in the 2nd form. How can i avoid this? NULL doesn´t work ...
1
vote
1answer
40 views

How to theme form?

I created a form in custom module, Something like: $form['form00'] = array( '#type' => 'textfield', '#title' => 'dummy', ); $form['form01'] = array( '#type' => '...
0
votes
0answers
19 views

“A fatal error occurred: Serialization of 'Closure' is not allowed”

I'm implementing a form using the Drupal form and AJAX. I've done this many times before, but now I stumble upon a problem I never seen before. My AJAX event is called when the value of a textfield ...
0
votes
0answers
21 views

Add form field dynamically but ajax submit and callback is not triggering

I try to create a for that can add and remove field dynamically through ajax. like this: use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Ajax\AjaxResponse; ...
1
vote
1answer
29 views

Chunked Ajax Responses

Does Drupal support chunked AJAX responses in either direction? I have not been able to find materials on this so far and am curious: Is Drupal AJAX capable of working with chunked AJAX responses (...
0
votes
1answer
17 views

Unable to delete a file with services

I am making an AJAX call to /file/.json. Webserver log says DELETE /services/file/5710.json HTTP/1.1 200, console log says the file has been deleted; yet the file is still there when you go here. What ...
0
votes
1answer
16 views

Save values after add more ajax in form api - field name issue

I've created a form using Form API and AJAX for an add more button, but I think I have problems assigning names to the new ajax fields in the loops, cause when I try to insert my data into my database ...
1
vote
1answer
87 views

How do I add/remove form fields dynamically?

i have form build in standard like: public function getFormId() { } public function buildForm(array $form, FormStateInterface $form_state) { } public function validateForm(array &$form, ...
1
vote
0answers
50 views

Custom template for each profile2 profile type edit form

I am working on a drupal 7 site and for a few days now, I've been struggling with this problem: I am trying to create a custom template for the edit profile form, but there are more profile types. I ...
1
vote
0answers
15 views

Is there a way to merge / update result rows in Views with AJAX rather than the default which replaces the whole view div?

In a view with Use AJAX:Yes we see that upon filtering we get a completely new set of results and the div.view is completely replaced. Is there a way to merge rows rather than replace all rows? i.e. -...
3
votes
1answer
25 views

Modal API not displaying ajax response

I am trying to use the Drupal 8 Modal API to output a link in a modal window - using the "Simple Link" approach here. When clicking my link, I get a little animated spinner and I can see the ...
0
votes
1answer
24 views

want to load the multiple select box field data as per selected category using ajax form alter?

I have list of select box like Team and Player with category option on top of the form. if i select the cricket in that category it should load players and Teams node title based on the category ...
1
vote
0answers
39 views

How to load a user field value using AJAX

I want show my users phone number in node.html.twig and I want that robot spammers can't access that. In other words, the phone number should not show up in the page in the initial page load. When a ...
1
vote
0answers
46 views

Update database/dom after dialog button submitted with jQuery

Clicking a dialog button I want to update Drupal database using jQuery .ajax() function! I want to know if in first place is secure to do so or is another method to handle the synchronous requests? ...
1
vote
0answers
14 views

Add a non-system confirm popup on node add/edit

I want a custom confirmation popup to come up when someone wants to save a new node or update an existing one. Of course, the form only submits/saves info if the user clicks Yes. As it is now the ...
0
votes
1answer
27 views

Why isn't the #ajax property available for more Form API elements?

Looking at https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7.x because I haven't seen a page updated for Drupal 8, it seems like only a select few form elements are allowed ...
1
vote
1answer
54 views

Cannot bind delegate onClick event on .use-ajax elements

I have a view, that is refreshed with ajax. I'm using Jquery 1.7.2 You click a button, that call a javascript function : $(view_identifier).trigger('RefreshView'); Before this refresh, I've ...
0
votes
1answer
23 views

What is the path for form elements which are ajax-enabled

I am working on the quiz module. I have to modify the form node/add/multichoice by hiding some of the form elements in it. With the help of krumo function of devel module, I am able to find the ...
0
votes
0answers
16 views

How do I create an autocomplete textfield? [duplicate]

I have a textfield, which should be autocompleted with the IDs of another entity ('context'). How can I do this? $form ['context_key'] = [ '#title' => t('Context key'), '#description' =&...
0
votes
0answers
19 views

Webform add a submit user confirmation

i want to add a step between the validation of the form (check if there is errors in the form) and the submition of the form (the moment when the form is saved). I want to show to the user a colorbox ...
0
votes
0answers
20 views

Ajax 403 Error Access Forbidden when editing views or creating blocks

I'm getting 403 Errors, Access Forbidden on a Drupal 7 site when trying to edit views or add blocks. The error doesn't always occur, but once it start it doesn't go away either. The hosting company ...
0
votes
0answers
41 views

Ajax form callback not executed

I wrote a quite simple ajax callback to alter a views exposed form block. Ajax is fired but no commands are returned. Each time I change the value of my ajax field, I get two logs in dblog : ...
0
votes
2answers
30 views

Values disappear in $form_state['values']

I have some tableselect in a form which I can click a button and update from a database. When I update it, I need to be able to access those values in my submit function. But those values aren't ...
1
vote
1answer
19 views

oEmbed Video Module loading via ajax for faster loading [closed]

Is there a module that lets you load in youtube videos via ajax? Currently I'm using oembed module ( https://www.drupal.org/project/oembed ) and it loads in the video js files which take up 1MB. I'm ...
1
vote
0answers
17 views

Push data to dataLayer on Webform Ajax submit

I'm using the Webform Ajax module to ajaxify my Webform and I need to push some data to the dataLayer to use with Google Tag Manager after a successful submit. Like: dataLayer.push({ 'event': '...
0
votes
2answers
53 views

How to get selected Value in the listbox by using form api

I have created a form with fields titled State and City. After selecting the state's appropriate city records, they will be loaded into city listbox. Until now they were working fine, but after ...
0
votes
1answer
26 views

How do I conditionally add a field?

I'm trying to find out any example of adding new conditional field using ajax in Drupal 8 form API, but I can't find it. This is my code. $form['name'] = array( '#type' => 'textfield', '#...
0
votes
0answers
19 views

after ajax callback, how to alter views exposed form

Look at my code is there any other way to do this. I tried to change my form element type in my exposed view filter after selecting any dropdown menu and my dsm($form_state) not showing any [values] ...
0
votes
0answers
37 views

How to restrict submit handler when ajax button is clicked in altered form

I am altering ubercart "uc_product_add_to_cart_form" and adding an ajax button "calculate price": $form['price_calculation']['calculate'] = array( '#type' => 'button', '#value' => ...
0
votes
0answers
14 views

Input values of fields added NOT by ajax are not present in $state['values'] nor $state['input']

I have a form with the default set of fields on page load and with buton "add product". That button is appending the same set of fields into the form. Every set of fields has a button "calculate price"...