Stack Exchange Network

Stack Exchange network consists of 174 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
20 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
32 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
0answers
41 views

How to create depended fields in drupal custom module [duplicate]

I know this has been asked before and I'm trying to use the example at Dynamic select list in the form (dependent dropdown) but I am struggling to get the desired results. I Have a form that presents ...
2
votes
1answer
44 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
27 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
29 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
29 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
19 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 ...
-2
votes
0answers
18 views

Display Block After some time using ajax?

I have alter the webform block after some times to display in page. for example. The Block should be display to the user after the one minute. I have rendered the block in some region and the block ...
-1
votes
0answers
25 views

control views contextual filter; ajax

I would like to implement a view exposed filter that filters by Year. I need to use ajax. I do not want to create a new field that saves the year as a simple integer and instead use the existing built-...
4
votes
1answer
72 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
22 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 ...
-1
votes
0answers
17 views

Ajax error on form submit

When I submit the form on the website(example: http://www.megatechnika.ru/node/109/ ) the form isn't sent to the server. And there is an alert showing with /system/ajax/ 500 error and a following text:...
0
votes
0answers
24 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 ...
-1
votes
0answers
66 views

Ajax link not working when in Twig loop

I am trying to create ajax links in a twig template (not in a form) in Drupal 8 and have run into a strange phenomenon. I have managed to create a simple link that opens an alert. This works when I ...
0
votes
1answer
23 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
35 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
17 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
22 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
34 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
29 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
26 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 ...
0
votes
1answer
34 views

Changing form field requirement via ajax

I have a selectbox field, that should change the disabled and required states of another field based on the value selected in the selectbox field. The change must be done via ajax. In my modules ...
0
votes
1answer
21 views

AJAX ReplaceCommand executes as expected only on first iteration

Expected Output: User triggers remove item button. Program updates database. Form gets rebuild with updated information from the database. AJAX replaces the old information with new information from ...
0
votes
1answer
53 views

Modal Form Submission

I have a modal form that I added to my module and patterned it after this article. I have used it before with no issues, I was able to use the method to show the form and then save the data. Now ...
0
votes
0answers
23 views

AJAX Form Not Submitting Until After Cache Clear

I'm working on a module that needs to add a form to a page that submits via AJAX. My form consists of a text field and a submit button with callback: $form['my_text'] = [ '#type' => '...
-1
votes
0answers
22 views

Form submit doesn't work first time

When orgno changes brreg_field_ajax_callback is called, company field is filled by js (And it's ok, work fine); but when i click on submit (there are other fields, without #ajax) the page is refreshed ...
-1
votes
0answers
57 views

How to add new elements to draggable table

Hi I'm having some issues with a table to add new elements ive created a form with a draggable table if a add elements manually the table show weight and thats ok but i want to add new elements when ...
-1
votes
0answers
21 views

Add binding to “keyup” or “input” to an autocomplete textfield

I have an autocomplete textfield with an #ajax callback on autocompleteclose: $form['myfield-container'] = array( '#type' => 'container', '#attributes' => array( 'class' => array( ...
0
votes
0answers
58 views

Ajax form: Rebuild form and show popup

On my ajax submit form I would like to rebuild the form and show a dialog. Here's the code I have used. public function buildForm(array $form, FormStateInterface $form_state) { if ($some_condition == ...
-1
votes
0answers
24 views

Form API states not working when form loaded via Ajax

Drupal form #states not working when I am loading form via jQuery Ajax. $form['activity_container_' . $i]['new_comment_' . $i] = [ '#type' => 'textarea', '#title' => t('Your ...
0
votes
0answers
16 views

no data is stored in cache_form table (Ajax 200 error)

I am using Drupal 7.59 and Drupal Commerce 7.x-1.14. After we updated our PHP version from 5 to 7 and migrated our database to AWS RDS. We started getting a lot of Ajax 200 error(Invalid form POST ...
2
votes
0answers
83 views

How to change the title of a modal window?

I have a link that displays a modal window. The link redirects to a page view. When I click on it, it is marked in the title of the modal window Array. How to customize the title ? <?php ...
0
votes
1answer
29 views

How to execute ajax into block view

I'm in Drupal 7. I would like to execute an ajax function in my front-page. I've defined the block view in my ".module" file. When I change the selected option, the log gets two errors: 1. Warning:...
6
votes
1answer
544 views

How to prevent an Ajax form from submitting

The below code blocks any non-ajax form from submitting. $(this.form) .on('submit', function(event) { if (/* Some condition */) { event.preventDefault(); } }); In Drupal 8, how can ...
0
votes
1answer
46 views

How do I update the CKEditor text widget using CKEditor API

I am using Drupal 8's Ajax API to update form fields in a form depending on the input in another field. One of the fields I want to update is a text_format field that uses Drupal's ckeditor. If I ...
0
votes
2answers
74 views

Language detection by domain breaks ajax requests over https

What do I have: Drupal 8.6.2 Domain Access Language modules Cloudflare with https Problem: If in URL language detection option (/admin/config/regional/language/detection/url) I have "Path prefix"...
0
votes
1answer
37 views

Off canvas dialog using a button

I am trying to adapt the relatively new off canvas dialog introduced in Drupal 8.5. It is suggested to use it with the Drupal Form-API and a link element like this: $form['off_canvas'] = [ '#title'...
1
vote
1answer
32 views

Is the AJAX from image fields and multi-line fields breaking my JavaScript?

We have added tooltips to our node form using this method: https://inclusive-components.design/tooltips-toggletips/ It includes a JavaScript/jQuery snippet that works perfectly except... If the ...
0
votes
1answer
36 views

How to iterate over AJAX-added form elements

In this snippet, located under src/Form/DocumentCreationForm.php, I create an AJAX callback that adds more section elements to the form when the add section button is clicked. Now I'm trying to read ...
0
votes
1answer
27 views

Failed to load popup dialog with in views

I am using Drupal 8.6.1 with the 8.x-1.0-alpha2 Footable module and the core dialog. What I did so far: Install the Footable module. Download the most recent 3.x.x version of the FooTable jQuery ...
0
votes
0answers
25 views

How can I iterate over dynamically added form elements?

I got AJAX working with the AppendCommand, so that every time the Add button is clicked, a new "section" is added to the form. How do I iterate over all these elements in the validation and ...
0
votes
0answers
25 views

Sending ajax message using jQuery

I am using better exposed filters on my view and I need functionality, so that a second click on the same filter would reset filtering at all and give back all results, sadly I didn't find a solution ...
0
votes
0answers
28 views

How to Regenerate CSRF token on Ajax callback handler

For some reasons, I don't want to rebuild the whole form on Ajax, but I want to regenerate CSRF token on ajax callback handler, Is there any way to regenerate form CSRF token on ajax callback handler?...
0
votes
1answer
30 views

Alter existing form and add element with an ajax “add more” button

I am altering the field settigns form, in order to add custom settings. I used the example module as a guide and added my code in the following manner: /** * Implements hook_form_FORM_ID_alter() for ...
0
votes
1answer
41 views

My Ajax call for my submit button does not work?

I am building a form with the form builder but I can't even get my button to use its ajax function to callback. Instead of doing a normal ajax call on the page, it reloads the entire page. What am I ...
0
votes
0answers
56 views

Contextual filter in media browser view not accessible on autocomplete filter ajax call

I'm having a view which filters Media type and has contextual filter of Entity browser context. This view also has an exposed filter of text box field with autocomplete enabled which filters by media ...
1
vote
1answer
60 views

Drupal behaviors not attached after Ajax load

I'm facing a weird problem on my clean Drupal Installation I attached a js library to page with this function fs_gal_preprocess_page(&$variables) { $variables['#attached']['library'][] = '...