Ajax

Solution to: Call to undefined function node_form_validate on ajax form submit

If you're running into the JavaScript alert error message on creating an AJAXified node form:

Call to undefined function node_form_validate() ...

... the reason might be that the $form_states array contains wrong information which files to load on form build.

Drupal 7 API: Display Drupal Messages in/after an AJAX call

Sometimes you need a snippet to display the drupal messages (drupal_set_message) created messages after an ajax call as result (for example if a node was created via ajax).

The following snippet removes old messages from the site and appends new messages in the AJAX callback:

  1. function ..._ajax_callback(){
  2.   $commands = array();
  3.   $commands[] = ajax_command_remove('div.messages');

Drupal 7 API: Trigger views AJAX refresh via JavaScript or from PHP using ajax_command_invoke

Drupal 7 ‎Views‎ allows to refresh ajaxified views
dynamically via a javascript call.

Implementation in JavaScript

The JavaScript call is simple:

  1.   jQuery('.view-id-XXX').trigger('RefreshView');

Implementation in PHP

Fix Drupal Ajax Callbacks missing or wrong $language variable fallback to default language

If you should run into the same problem as I did and wonder that your AJAX callback results return in the wrong language, you may have missed to add the language (path) prefix to the AJAX call!

AJAX calls determine the language from the path they were called, if language prefixing method is used in Drupal.

Drupal 7 Views (3) add AJAXified RESET button for views exposed filters

Drupal 7 Views (3) provides great functionality. However the optionally provided "Reset" button for exposed filters does not work nice with AJAX.
If it is clicked it:

  • Does not fire via AJAX but loads a whole new page
  • Has a problem with the URL (see https://www.drupal.org/node/1109980) and so redirects the user to the front page in most cases.

Linktipp: Drupal Refresh View on AJAX Event

Der Titel sagt fast alles. So könnt ihr ein AJAX Refresh eines Drupal AJAX Views erreichen, nachdem z.B. eine Schaltfläche auf der Seite angeklickt oder ein Formular verschickt wurde...

Display Drupal AJAX Trobber / Spinner persistently for styling / theming purposes

Display Drupal AJAX Trobber / Spinner persistently for styling / theming purposes

Sometimes dymanic web pages are really problematic for styling purposes.
One situation is to style an AJAX Throbber / Spinner in Drupal, which hides very fast (in most situations ;)) and is only hardly stylable though. In this blog entry I'm describing a trick to keep the AJAX Throbber visible in its position.

jQuery AJAX Race Conditions verhindern und AJAX Aufrufe pipe'n mit jQuery.Deferred() in 5 Zeilen!

Die kleine Denkaufgabe des Tages: Wie schafft man es in möglichst wenig Zeilen eine Reihe von AJAX-Aufrufen, die anhand einer Schleife erzeugt werden, mit einer Pipe sequenziell abzuarbeiten?

Die Lösung:

  1. // A list of arguments for separate sequential AJAX calls.
  2. // First argument for first call, second for second call, etc.
  3. var callsArguments = new Array();

qTip - der etwas bessere Tooltip?

Vor einigen Tagen bin ich auf das jQuery Plugin "qTip" gestoßen und muss sagen, dass ich sofort überzeugt war.

Das Plugin bietet mit den Sprechblasen oder der einfachen Boxdarstellung viele verschiedene schöne Darstellungsformen. Auch technisch ist qTip gut ansprechbar und durch die vielseitigen Einsatzmöglichkeiten sehr flexibel.