Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ajax]

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

0
votes
0answers
17 views

$form_state values are empty after ajax $form modification

Im doing a module to generate form validation on field length, first i display a select of availble content types. When the target content type is selected an ajax request display the end of the form ...
0
votes
0answers
27 views

How to validated form with Ajax fields

I have a drupal custom form with two ajax dependent dropdown fields and five normal text fields. on form submit, all things are working fine except validation of form fields. when I put validations on ...
-1
votes
0answers
7 views

How do I integrate the recaptcha module in a contact form with ajax?

I have a contact form on the front page of my site, this form makes the sending of data with ajax, I incorporated the recaptcha but it does not work, any idea.
0
votes
1answer
28 views

How do I trigger a modal from a template that points to a controller returning an AJAX response

I am trying to trigger a modal from a twig. The path of the modal is a controller that returns an AJAX response as below: Routing code usgbc_myaccount.get_badges_evidence_controller: path: '/account/...
0
votes
1answer
35 views

Avoid repetitive API calling in form rebuild while submitting

I am calling external API in form build function. While submitting form gets rebuild and call external API again. How can I avoid repetitive API calls in the form's build function? I used form_state-&...
0
votes
0answers
18 views

How to switch between views displays through ajax

I do have a view with exposed filters and a quite hierarchical architecture of the data which demands multiple grouping and sorting criteria. because of different use cases, users need to change the ...
0
votes
0answers
11 views

Update programmatically (js) the images of a image field in edit form

I have an entity type which has an image field. I use the default form widget for this, and I can upload or delete the image. On the node edit form, I have also a pop-up widget with a javascript app ...
0
votes
0answers
13 views

Refresh title/block when validating a filter

I have built a views with filters. When we choose a filter, the results are displayed by ajax ('Use Ajax' option). I need to update the title of my views page, with the active argument of the view. ...
0
votes
1answer
25 views

Drupal 7 chosen module use ajax to fill the select

I have two select elements and depending on what I select in the first select element second should fill from ajax call. First one is the simple select second one use chosen. The problem is if I fill ....
0
votes
1answer
26 views

How can I update the values of an exposed view filter when another filter changes value?

I know there are several examples of this around, on a view with two exposed select list filters, I need to update the value of the second based on the value selected on the first. I can't even seem ...
-1
votes
0answers
29 views

Commerce Ajax Add to Cart is not working on the first listing of every page

I am now using the using the Commerce Ajax Add to Cart 7.x-2.11 mod, which is going quite well, but the add to cart button for the first listing on any given listing page doesn’t respect the new ...
0
votes
1answer
24 views

Form API + AJAX - Form doubles itself on submit

I've been looking for an answer to this for hours now. A) No matter what I do, the form will always be visible again after submit. How can I stop the from from displaying after a successful submit? ...
0
votes
2answers
36 views

how to implement Ajax callback on form_alter for entity field?

EDITED: I am able to display image for a field dropdown which have entity reference values to another content type. That is when a node content is edited or created. Note: I'm not creating form ...
0
votes
0answers
21 views

How to set #default_value for radio button on Ajax Callback?

I've a form having a radios and 'select list with Ajax callback event'. When user changed selection from the select box, I tried to set the default_value for radio button. but it doesn't work. In the ...
0
votes
0answers
35 views

Add custom ajax command to ajax response after webform is submitted

What I'm trying to do is to invoke some javascript after a webform is successfully submitted by ajax. To do that I followed this advice and created an EventSubscriber to intercept ajax response and ...
0
votes
0answers
21 views

How to open modal on form button click with data from callback?

I have a form button with ajax callback: 'button_ajax' => array( '#type' => 'button', '#value' => t('Add short name'), '#attributes' => [ 'class' ...
-2
votes
1answer
26 views

Is it possible to add an Ajax action on a button define in a twig view template?

I have a view for which I customized the views-view-field...html.twig template. On each row, I added a first button A which opens a modal with two buttons: Button B to confirm the action and Button C ...
3
votes
1answer
59 views

JS batch progress bar: possible to force refresh more frequently than every 1500 ms?

After initiating a js-based batch with batch_set(), and the redirect to batch do URL, the JS refresh interval is every 1500 ms by default. So status message and progress bar are only updated every 1 1/...
0
votes
1answer
55 views

Infinite scroll is firing multiple times

I have looked for other answers on the same topic but still cannot find a solution why the event is firing more times in my code: (function($, Drupal, drupalSettings) { Drupal.behaviors.news = {...
0
votes
0answers
15 views

How to trigger the display of Moderation Note frame?

I'd like to reuse Moderation Note module to provide its feature directly from CKEditor (I opened a feature request for that). I'm wondering how to trigger the display of the Moderation Note frame. I ...
0
votes
0answers
26 views

Get Arguments from URL for a view in which AJAx is enabled and filter are exposed

Below is my requirement I am facing an issue i want my exposed filter options to be dependent on the URL argument( i am using contextual filters), View is ajax Enabled, so i can not get the url ...
1
vote
1answer
22 views

Change checkboxes in a node edit form alter

I have a problem with an ajax function which doesn't work properly and I don't understand why. I done a similar thing long time ago in Drupal 7 and it seems I forget how it works. I have a node type ...
1
vote
1answer
38 views

How do I download a dynamically-created file in a form submission?

I've got a form that builds an array of data. On submission, it updates a table displayed in the browser, using AJAX; that works fine. I want a second submit button that downloads the same data as a ...
0
votes
0answers
37 views

Limit validation errors on ajax change and autocompleteclose

I have modified the node add and edit form for one of my custom types, adding a few ajax callbacks: a couple are on the onchange values of text fields, one on the autocompleteclose of an autocomplete ...
2
votes
1answer
37 views

How to have the autocomplete option with ajax in a text field?

I am struggeling with creation of tetxfield with autocomplete option for my Drupal 8. My Drupal website is multilingual, and on one view page we present some content in Default language, by typing in ...
0
votes
0answers
60 views

How to fix “An AJAX HTTP request terminated abnormally” while image upload

Every time while I am trying to upload image by using 'manage_file' in form api and click on upload it throws an error: An AJAX HTTP request terminated unexpectedly Debug information follows. Path: /...
0
votes
0answers
18 views

Restrict ajax throbber to specific form id

Can we restrict below code to specific form ,currently its working on all form wherever ajax is calling. I am using ajax throbber module in drupal 7. <?php /** * @file * Drupal module file ...
1
vote
1answer
190 views

Controlling a dependent field in a multi-instance paragraph

The fields below are part of the node/add node/edit forms of my custom node type. The paragraph field_para_city contain one field_city. (I later need to add other fields in the paragraph). The user ...
0
votes
0answers
69 views

AJAX on Select Element throws: The specified #ajax callback is empty or not callable

The Problem: I have 5 select elements in my form, all are linked to their own ajax callback. Each select element has the same wrapper because the whole container should be updated when any of the ...
0
votes
0answers
34 views

Stack ajax_command_replace commands?

I am wondering if it is possible to stack two ajax_command_replace commands. In other words, to have code that looks like this: <br> $commands = array();<br> $commands[] = ...
2
votes
3answers
159 views

Does an ajax callback work within a Views style plugin?

My module has a custom Views style plugin. In the style settings form, I want to implement an ajax callback, such as described here: https://www.drupal.org/docs/8/api/javascript-api/ajax-forms ...
0
votes
0answers
28 views

Pagination with entity

Don't know where to start and not sure if there is already some builtin functionality that can be used. I have an entity and items on the page are rendered with class ItemEntityListBuilder how can I ...
0
votes
1answer
50 views

AJAX SettingsCommand Usage

Class Documentation: SettingsCommand I'm trying to figure out how to use this Ajax Command correctly. I must be confused from the documentation, so I'm hoping someone can shed some light where I'm ...
0
votes
0answers
10 views

How to edit an order to add the shipping line item to prevent AJAX error [duplicate]

Using Drupal 7.61 and Drupal Commerce 7.x-1.14 (+ Commerce Shipping 7.x-2.3 and Flat Rate 7.x-1.0-beta2) My client has (probably) deleted the shipping line item for an order and he has tried to edit ...
2
votes
1answer
61 views

AJAX doesn't work in custom form element

I want to create a custom form element for email that have a textfield and button and when click button send an email but ajax not working inside form elemen class. I test it in form api and it's ok ...
0
votes
0answers
95 views

How to display a form in modal dialog on page load?

This is on Drupal 8.6, PHP 7.2, Theme is based on Bootstrap. The scenario is, I want to display a dialog box with a subscription form in the home page. The dialog box will be loaded automatically ...
0
votes
1answer
36 views

Redirect to a specific page in ajax callback

How can I redirect to a specific page in an ajax callback using Drupal 7, I've already tested this method: function my_ajax_callback($form, &$form_state) { if (!user_is_anonymous()) { ...
1
vote
1answer
74 views

Creating a table with pagination in a Node Edit form

I have a content type article that has a field for Category. In order to help our editors find related articles, I included a table on the article Edit page that pulls in other article entities that ...
2
votes
0answers
22 views

How can I prevent the theming layer being loaded for JSON requests?

I can verify that views-exposed-filter.tpl.php is being loaded for basic JSON endpoints that don't re-render any form fields: My autocomplete - /search_api_autocomplete/...
1
vote
1answer
23 views

AJAX callback issue when using 'Manage Form Display' and 'Manage Display'

Good day everyone, So I have an issue that I haven't been able to google. The issue seems rather simple but I don't know what's causing it. When i'm managing field displays in either the form or a ...
4
votes
1answer
148 views

How to add autocomplete to a textarea on a form?

I would like to add autocomplete functionality to a textarea form element in Drupal 8. I have a fully functioning custom textfield which has autocomplete working on the same form. I have confirmed ...
0
votes
1answer
37 views

Using JCF with dynamic forms

I want to use Javascript Custom Forms (JCF) to get more attractive and consistent looking forms on my Drupal 7 site. I've got it working to a degree, however when the form changes with AJAX, the new ...
0
votes
0answers
39 views

Call an ajax command after another one ends?

I have a group of ajax commands that I must execute, but there is one that should only be executed once another has been completed. How can I call another ajax coamdo only when another one is ...
0
votes
1answer
82 views

Custom Ajax forms with managed_file form element

We have a form with three fields - where depending on the value of the first select field, we will show the other two form elements - one select field (the options depends on the value of the first ...
0
votes
1answer
67 views

is there an alternative for hook_views_ajax_data_alter in drupal 8?

As the title sais, is there a similar behavior like hook_views_ajax_data_alter in drupal 8 like in 7? If not has anyone achived the same result programatically? Thanks in advance.
0
votes
0answers
22 views

Link with callback function

How can I build a link with callback function like this, but without necessity of href: $form['link']= [ '#type' => 'link', '#ajax' => [ 'callback' => 'myFunctionCallback', '...
0
votes
1answer
25 views

Commands character limit?

I have 2 functions in a custom AJAX callback which are really confusing me, one returns an image from a single node, the other retrieves a list of nodes first, then loops through them and returns ...
0
votes
1answer
48 views

Pass list from Jquery to form

I have an AJAX form that I've created into a block exposed on my current page. I will have an interface that will allow the users to select an indefinite amount of content to be used within the submit ...
0
votes
1answer
33 views

cant loop through array with ajax_command_html [closed]

im beginner in drupal and i would like to ask why is this not looping , it just gives me first result $string = $form_state['values']['search_block_form']; $query=db_select('node','n'); $query-&...
0
votes
0answers
37 views

use-ajax Class does not work if used in multiple views?

What seems like a pretty straight forward implementation of ajaxifying a link is not working if I use it in more than one view block on the page. I have a route that calls a function. In my view I ...