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

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

0
votes
0answers
22 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
14 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
23 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
18 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
53 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
19 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'][] = '...
0
votes
0answers
46 views

After an unsuccessful form validation the ajax callback is not found

In hook_form_alter() I added validation handlers using the following code. function calculate_allocation_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'node_work_plan_form') {...
0
votes
1answer
23 views

Error 404 when upload image in profile installation

I am installing a custom distribution, I have created a form: my_distribution.install: /** * Implements hook_install_tasks(). */ function my_distribution_install_tasks(&$install_state) { $...
0
votes
1answer
28 views

Add mini pager and infinite scroll to a view

I have a view where at first 1 item has to show. On click of 'load more' next item has to show and so on. For this i have installed 'infinite scroll module' in drupal 8. Now after showing four items, '...
-1
votes
0answers
8 views

ajax callback when modal closes [closed]

How could I add a callback when the close button (cross) of a modal is triggered ? No issues for opening, refreshing, submitting forms and modal, but for multistep forms, when closing the modal, I ...
1
vote
1answer
52 views

Multiple form buttons with AJAX, how to update form state storage data?

I have a form built with the Form API that has multiple button form elements. I don't want any of these to submit the form normally, I want them to utilize #ajax and callbacks to update the display. I ...
0
votes
1answer
38 views

How do I override ajax-progress-throbber in a theme?

In my Drupal 7 site, I created a custom theme. In my theme, I want to change the AJAX progress throbber HTML structure, which by default is the following one. <div class="ajax-progress ajax-...
0
votes
0answers
20 views

AJAX HTTP 200 Error during database update following security upgrade

New user here. I am performing a test installation of Opigno 2.0 beta 3, which is based on Drupal 8. I haven't added content yet as I'm trying to get the site functional first, so wiping and ...
0
votes
0answers
30 views

How can I save DOM element changes from jquery, to the database on form submission

I've done this at least once before, but I can't find where I did it. I have a CiviCRM form which I am running calculations on and editing the DOM with the new values. The problem is that the DOM ...
0
votes
0answers
22 views

Rendering of an autocomplete field changes after being updated by an Ajax call [duplicate]

Inside my HOOK_form_alter I have a custom field defined in this way: $form['struttura-container'] = array( '#type' => 'container', '#attributes' => array( 'class' => array( '...
0
votes
0answers
28 views

How to add custom AJAX functionality to views form

I need to add a button to an exposed views form that is available for logged-in users. This button should perform some actions via AJAX when clicked. The form has AJAX enabled. I used the following ...
-1
votes
1answer
32 views

Unable to pass the value from .module file to JS using the implementation given below

.module file function taxonomy_fancybox_menu(){ $items['fetch-popup-markup-data/%'] = array( 'title' => 'Store markup', 'page callback' => 'ajax_fetch_markup_popup_data', 'page ...
1
vote
1answer
27 views

Two forms on one page break submit

I have two forms on a node page (the comment one + a custom form). Ajax is not enabled for both of them but still, when submitting the custom form form_set_error or durpal_set_message are not ...
0
votes
1answer
17 views

Autosave nodes, when editing or creating new ones, in database

Looking for a way to actually save nodes every x seconds when creating or editing. I am aware of the Autosave module, which is a great module but it only saves the forms on clientside and has quite ...
0
votes
1answer
32 views

How do I alter a form using an AJAX callback?

I have this callback function triggered by an onChange() event in another select box. This code, however, doesn't make the field enabled public static function changeForm(array &$form, ...
1
vote
1answer
74 views

Ajax Form on load Event

Is it possible for a Drupal Ajax form to automatically fire a callback when a page is loaded? I know this is possible using an external JS file and doing it through Drupal behaviors, however I would ...
0
votes
0answers
26 views

add ajax behavior to a custom field

I have two custom fields Region and State. You can see the implementation of Region at this link: Region custom field I want to add an Ajax call to the field Region onchange event that gets a list ...
0
votes
0answers
36 views

Request query being replaced in a view

I have created a custom block and attached it to a view header. I just can't figure out why the value returned from \Drupal::request()->query->get() is being replaced from views=ajax?...
0
votes
0answers
41 views

How come my view block is not loading using ajax?

We have a view, myview, that has an exposed filter title (text input). The view has Exposed form in block:Yes and so we load it onto the page under admin/structure/block. The block has a machine name ...
0
votes
1answer
59 views

How to load a library only once, or how to check if a library has been loaded?

I am making an asynchronous single page application in Drupal 8. So far everything is working nicely. However, it has a lot of libraries that are needed for a lot of different things, depending on ...
0
votes
1answer
38 views

How reset $form_state on ajax call for get real value in submit?

I have see some post about that,but i still have no real answer. In my form, user can select a register address in a select field. When he select an address, the ajax set value on some other fields : ...
0
votes
0answers
22 views

Nested AjaxAddMore using Drupal FAPI

Using examples module as a reference guide, I'm able to implement the AjaxAddMore functionality into one of my configuration forms, but somehow when I'm trying to achieve the same logic by further ...
1
vote
1answer
76 views

Reset a form element value through AjaxResponse

I have an AjaxCallback which returns AjaxResponse(). I need to change some form element properties like (disabled to true, remove some css class etc which works). But I'm unable to reset the ...
1
vote
1answer
48 views

Form element replaced via Ajax callback doesn't seem to be submitting or the values are not appearing in buildForm

I'm having a form with a select list and a textbox. On-change of select list will trigger an ajax callback. The callback function will replace the default value of textbox with an updated value. But ...
0
votes
1answer
62 views

Disable /Enable a multivalued paragraph field on Ajax calls

I have 2 fields in a form. One select list and another entity reference field referring to a Paragraph type (multivalued). The on-change event should trigger an ajax callback which will disable some ...
1
vote
1answer
32 views

How do I pass the language through ajax request

I have an ajax function in the javascript file that calls for the data in a custom module. But the problem is it always get the data for the default language. In my case it is 'en'. How do I get the ...
0
votes
1answer
22 views

Why can't I change textfield #default_value based on checkboxes' values after an AJAX response?

I have been trying to learn Drupal forms with AJAX recently and from my current understanding of it I thought I should be able to do something like presented below (I wanted to store all selected ...
0
votes
1answer
22 views

Embed unique custom form in all rows of a view

I want to create a custom form that will be embedded on each row for visitor to submit an email for that specific row. I suppose I have to create a custom form (which I have done before) but how do ...
0
votes
2answers
19 views

select list sending old value in ajax request

I have a select list on custom module form, on it's select giving ajax call and populating the second select list. But when I select the value from the first list, it is passing old value (previously ...
0
votes
0answers
14 views

Getting problem in drupal form validation having ajax fields and other fields

In Drupal 8.5.6, I have a form with one ajax dependent dropdown field and two more other normal text fields. But when i give validation to form, when text field validation fails ajax fields gets reset....
0
votes
1answer
78 views

Behaviors are only called the first time a view is loaded

On a Drupal 8 site I have a world map where the user can click on a country; a view with content is then loaded with AJAX using a custom module and the following JavaScript. (function($, Drupal, ...
0
votes
0answers
16 views

How to render an AjaxResponse manually? [duplicate]

I have a Drupal 8 form within an AjaxResponse that I want to manually invoke from a JavaScript file. What is the best way to do this? Will the jQuery load() function work?
0
votes
1answer
25 views

Preserve ajax call status

I'm trying to hide/disable field when the user select an option (Example at images). Image A Image B I've tried to used AJAX, JS or #states from Drupal 7, and it works, but when the user press "...
0
votes
0answers
22 views

How can I render a modal dialog? [duplicate]

I'm trying to render a Drupal 8 modal dialog form through JavaScript, so it can appear on multiple pages across my site. In the controller class, I create an AjaxResponse object with an ...
0
votes
1answer
87 views

How do I render a form with JavaScript?

I'm trying to render a Drupal 8 modal dialog form through JavaScript, so it can appear on multiple pages across my site. In the controller class, I create an AjaxResponse object with an ...
1
vote
0answers
57 views

How can I invoke an AJAX response?

I have a Drupal 8 form I want to show via JavaScript code to make it appear as a popup across multiple pages. The form is rendered through an AJAX response in a controller. I can see the response ...
0
votes
0answers
38 views

How to access an Ajax callback return value?

First a confession: I did not write the JavaScript reproduced below. Unfortunately, I am a rookie JavaScripter, and this script was scavenged from another project and slightly adapted by me. The ...
0
votes
1answer
34 views

Trigger ajax action by url or link

I currently have a page which has a block with taxonomy terms displayed. Each link has been made to work with ajax to display information below if clicked, generated in a module callback. What I am ...
0
votes
0answers
30 views

Dynamic options/values (by ajax depending on choices / changes on other fields)

What would be easiest way to have dynamic radio buttons on Webform? By dynamic I mean that the options can change upon changing other controls without submitting. I think easiest would be to use ...
0
votes
0answers
161 views

Form ajax submit handler not called when loading in ModalDialog from submit handler of another form - Drupal 8

I've custom form (suppose FORM1) with few fields and AJAX submit button. When user submit this form, I'm opening another form (suppose AJAXFORM1) in ModalDialog with few more fields and AJAX submit ...
0
votes
1answer
19 views

Table doesn't render on ajax command

I have a function that returns a render array for a table; private function _files_table($job_id){ $files = $this->_query(" select * from JC_Documents_Recent_Revisions ...
0
votes
2answers
23 views

Can an AJAX form request replace elements of different types?

I'm trying to write an AJAX form in Drupal 8. I managed to get a simple example working yesterday, but today, my work fails without error. I was wondering whether anyone here could spot my error. ...
0
votes
1answer
43 views

Create a Custom Ajax in form alter

Hi i have a problem to create a custom ajax, i have the following code. the problem is i cannot make the code working no response nothing working for ajax callback, is simple but i try to put i src ...
0
votes
1answer
23 views

AJAX Views arguments: how to specify quantity of results and what are other options that can be used?

From this great answer I have a working jQuery implementation of a simple call to an existing view using AJAX. Which is brilliant, but I want to specify the number of results differently to as is ...
0
votes
0answers
342 views

Capturing the event of “add another field value” and current form state

I built a content type (journey plan) to allow users to choose steps in a cross-countries journey. The users choose a country from a menu (field_country), and put one or more cities from that country ...