2

how to add a JavaScript file in Ctools modal popup ?

I added the js file (datatables.js) in the .tpl.php file but it does not work?

The popup does not detect this file?

drupal_add_js(drupal_get_path('module', 'my_module') . '/jquery.dataTables.min.js');
mzy
  • 1,754
  • 2
  • 20
  • 36
rami
  • 51
  • 3
  • Does the JavaScript get attached to the main page? If so it is acting on the modal window as well. What is triggering running your javascript? The modal wont be there for window load or ready you need to use behaviors. – Joel Johnson Nov 05 '14 at 21:16
  • You should add that in the callback function for the menu item of that modal – Ziftman Dec 12 '14 at 21:08

1 Answers1

1

We're using document.ready and ajaxComplete:

$(document).ready(function () {
Drupal.behaviors.nameSpace.functionName();
});

and

$(document).ajaxComplete(function () {
Drupal.behaviors.nameSpace.functionName();
});

Clearly not a DRY solution, but it solves the problem for now.

esod
  • 335
  • 2
  • 9