Skip to content

Instantly share code, notes, and snippets.

@tmsss
Created November 12, 2013 21:54
Show Gist options
  • Save tmsss/7439462 to your computer and use it in GitHub Desktop.
Save tmsss/7439462 to your computer and use it in GitHub Desktop.
Binding ctools modal handlers dynamically without page reload from http://www.nextide.ca/node/672
$('area.ctools-use-modal, a.ctools-use-modal').each( function() {
var $this = $(this);
$this.unbind(); // Note the unbind: Otherwise there are multiple bind events which causes issues
$this.click(Drupal.CTools.Modal.clickAjaxLink);
// Create a drupal ajax object
var element_settings = {};
if ($this.attr('href')) {
element_settings.url = $this.attr('href');
element_settings.event = 'click';
element_settings.progress = {
type: 'throbber'
};
}
var base = $this.attr('href');
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment