Created
November 12, 2013 21:54
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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