drupal dominate

14
Drupal DOMinate Stories of masochism on the front end Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

Upload: steven-rifkin

Post on 13-Jan-2015

230 views

Category:

Technology


0 download

DESCRIPTION

Drupal DOMinate was presented by Matt Wrather and Steven Rifkin at the Los Angeles Drupal User Group meetup 5/14/13. The presentation covers the use of the Drupal Javascript API focusing on the behaviors and settings objects.

TRANSCRIPT

Page 1: Drupal DOMinate

Drupal DOMinateStories of masochism on the front end

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

Page 2: Drupal DOMinate

AgendaSteve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

Worst Practices

Best Practices

Drupal.behaviors{}

Drupal.settings{}

Questions

Page 3: Drupal DOMinate

Don’t hack coreIf I update jQuery versions it works it doesn’t work!

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

Stories from the front-end lines

Page 4: Drupal DOMinate

Better/Best PracticesSteve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

jQuery Update modulehttp://drupal.org/project/jquery_update

Using closurehttp://drupal.org/project/jqmulti

Page 5: Drupal DOMinate

Drupal DOM objectWhip out your web inspector, firebug, dev tool flavor and take a peek

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

Drupal {}

Drupal.settings{}

Drupal.theme()Drupal.locale{}

Drupal.behaviors{}

Page 6: Drupal DOMinate

Drupal.jsLet’s have a read

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'locale': {} };

Page 7: Drupal DOMinate

Drupal.behaviorsMan I wish I knew that before

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

Page 8: Drupal DOMinate

Drupal.behaviorsMan I wish I knew that before

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

So how should I load my script on the page?

Page 9: Drupal DOMinate

Drupal.behaviorsMan I wish I knew that before

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

Page 10: Drupal DOMinate

Drupal.behaviorsMan I wish I knew that before

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

Drupal.attachBehaviors();

Page 11: Drupal DOMinate

Drupal.behaviorsMan I wish I knew that before

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

$(“#element”).doSomething();

$(“#element:not(.processed)”).addClass(‘processed’).doSomething();

vs

Page 12: Drupal DOMinate

Drupal.settingsAnother way of using drupal_add_js

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather

Page 13: Drupal DOMinate

Drupal.settingsAnother way of using drupal_add_js

Steve Rifkin & Matt Wrather LA Drupal 5-14-2013 @steverifkin @mwrather