New answers tagged

1

Just added a video link to show you : imgur.com/EmVha6e You just need to add a conditional to check if it's not ajax $request = \Drupal::request(); $is_ajax = $request->isXmlHttpRequest(); if (!is_ajax) { // code that sets the filter initial value } Credit: How can I detect AJAX request inside Drupal?


0

This code uploads one file with Ajax, attaching it to an existing node's file field. The content type is file_test, and the field is field_da_files. (I'm not a professional programmer, so there are no doubt better ways to do this.) Here's some HTML/JS that talks to a Drupal controller. It sends the node id, and the file to be stored. In uptest.html.twig: ...


0

SOLUTION: Got this working with the following. You have to set the #ajax property on the widget // Set the ajax function to run on the change of filing category. $form['category']['widget']['#ajax'] = [ 'callback' => '_ajax_form_category_change', 'event' => 'change', 'wrapper' => 'ajax_id_data_type', 'method' => 'replace', ];


2

Your AJAX needs to have a target ID where it will put your AJAX output. You declare that ID in the wrapper key. In your form_alter '#ajax' => [ 'callback' => 'xyz_user_signup', 'wrapper' => 'load-me-here-id', // This element is updated with this AJAX callback. ], Then you need to wrap the field with this ID so AJAX replaces it. $...


2

Ok, So thanks to 4k4 I now understand what i was doing wrong, and for the favour of everyone that will meet this issue again: The form_alter is invoked as well when ajax callback is invoked. by the time the execution got to my ajax callback (getAjaxArgumentsFields) the form_alter has already altered my form, so all i had to do was return the fields without ...


0

There is a little hack with php. And it works not only with Google, but with any website you don't control and can't add Access-Control-Allow-Origin * We need to create PHP-file (ex. getContentFromUrl.php) on our webserver and make a little trick. PHP <?php $ext_url = $_POST['ext_url']; echo file_get_contents($ext_url); ?> JS $.ajax({ ...


Top 50 recent answers are included