5. The DOM has to be ready
$(document).ready(function() {
// Code Goes Here
});
6. The DOM has to be ready
$(document).ready(function() {
$(“#tabs”).tabs();
});
7. The Drupal Way
Drupal.behaviors.loadTabs = function(context) {
// Code Goes Here
};
8. The Drupal Way
Drupal.behaviors.loadTabs = function(context) {
$(“#tabs”).tabs();
};
9. Why use Drupal.behaviors?
• Ability to override JS
• Behaviors are re-attachable
• Attach Behaviors to a specific context
• HTML loaded via AHAH
10. Why use Drupal.behaviors?
• Ability to override JS
• Behaviors are re-attachable
• Attach Behaviors to a specific context
• HTML loaded via AHAH
Drupal.attachBehaviors(elem);