JTL-Shop 4: AJAX events / hooks / bindings "contentLoaded"

Ein typisches Problem im Umgang mit AJAX ist die (re-)Initialisierung von Scripts auf den nachträglich geladenen Inhalt. Im JTL-Shop 4 stößt man darauf beispielsweise auf Kategorieübersichten bei der Seitennavigation.

Viele Systeme, viele Lösungen

Drupal 7 entityreference autocomplete: Improve the ENTER keydown behaviour (select first on enter)

I created this issue and snippet as better entityreference.module autocomplete widget usability solution in: ‎

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.module 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();