As the title described, when we open a ctools modal in the Android phone, the content loaded through AJAX will not be shown and progress bar displays all the way.

After digging up the code and I found the extended Drupal AJAX command function:

$(function() {
  Drupal.ajax.prototype.commands.modal_display = Drupal.CTools.Modal.modal_display;
  Drupal.ajax.prototype.commands.modal_dismiss = Drupal.CTools.Modal.modal_dismiss;
});

are wrapped in the jQuery.ready() function which is not supported in the Android. Instead, it supports deviceready.

Check document.ready function of jquery not working in android

I notice usually the AJAX command extended functions are written straight away instead of embedding in the jQuery.ready() function. The reason why it is there in Ctools module, probably because sometimes modal.js is loaded ahead of misc/ajax.js.
In another word

drupal_add_js('misc/ajax.js');
drupal_add_js('sites/all/modules/ctools/modal.js');
drupal_add_js('misc/ajax.js');
drupal_add_js('misc/ajax.js');

The order will be

sites/all/modules/ctools/modal.js
misc/ajax.js

This does not always happens, see #1388546: Adding CSS or JS files twice changes weight

The solution for the time being is just removing two lines

//$(function() {
  Drupal.ajax.prototype.commands.modal_display = Drupal.CTools.Modal.modal_display;
  Drupal.ajax.prototype.commands.modal_dismiss = Drupal.CTools.Modal.modal_dismiss;
//});

Comments

merlinofchaos’s picture

Not supporting ready() seems like a major deficiency. A lot of our javascript uses ready. I'd think absolutely nothing would work, ever.

eric.chenchao’s picture

Yes, that is annoying. But by simply commenting this two line it seems work properly so far.

cweagans’s picture

Issue summary: View changes

Add reference