Big Bang Technology, June 2008, Max Cameron, iPhone, Web Dev, Flex Development, Bigbangtechnology.com
abstract away inconsitencies in browser. each does it different functionally equivalent small differences in edge cases
interesting history. one of the first modern JavaScript frameworks designed to mimic the Ruby in the browser.
Interactive sophisticated programs in the browser. Typically without page refreshes.
Most of those accomplishments go to jQuery, and I'd highly recommend using it for most simple JavaScript implementations.
* visual representation of the class instances * events are bound * loaded via ajax from a json feed
Creating a class instance with optional parameters Inserting custom instances into the DOM Accessing the public API of a class instance Class instances maintain state regardless of whether they are in the DOM or not.
explain the html structure of the dom nodes
Object.extend overrides default options with whatever is passed into the constructor If something isn’t passed in, the default value is used
you can take any DOM element and use the .insert method on it to insert custom classes as long as they implement toElement as an instance method.
Element is a class built just like Ninja. It takes two arguments, the tag name, and a hash of attribute values that you’d like to see on the element. Update is an Element method that lets you add elements or text as children
if you don’t use bind on event listeners. “this” references the element that dispatched the event. but we want to reference the class instance to access properties inside it. interpolate makes adding variables to strings a lot easier
custom events need to be bound to dom elements. use custom events for public methods that change the visual appearance of the class
iterate through the JSON to create new class instances for each record found. typically would be database driven. don’t forget to store a reference to the class instance or JavaScript will garbage collect it
Notice how the JSON feed is styled with the same key values as our class constructor options.
1 Favorite
David Lafon, Web developer - Testing & Quality at groupe Reflect - Emakina group, favorited this 8 months ago
Agenda
• General Framework Overview
• What Prototype Isn’t
• The Ninja Database
• Questions?
Thursday, February 19, 2009
jQuery
Awesome.
Thursday, February 19, 2009
Prototype
Awesome.
Thursday, February 19, 2009
Frameworks
Awesome.
Thursday, February 19, 2009
Javascript
Awesome.
Thursday, February 19, 2009
Browsers?
Thursday, February 19, 2009
Prototype ==
jQuery
Come on, they all basically do the same thing.
Thursday, February 19, 2009
Ruby in the
Browser?
Not quite.
Thursday, February 19, 2009
AJAX
The umbrella term
Thursday, February 19, 2009
So why Prototype?
Thursday, February 19, 2009
Light as a … NO.
Thursday, February 19, 2009
Quick as a … NO.
Thursday, February 19, 2009
jQuery is Champ.
Thursday, February 19, 2009
Prototype Has
Muscle.
• Class Creation
• Insertion
• DOM Element
Creation
• Events
• Custom Events
• Scope Binding
• AJAX
Thursday, February 19, 2009
The Ninja Database
Thursday, February 19, 2009
Thursday, February 19, 2009
Controlling Class
Instance via Firebug
• Creating a class instance with
optional parameters
• Inserting custom instances into the
DOM
• Accessing the public API of a class
instance
• Class instances maintain state
Thursday, February 19, 2009
Thursday, February 19, 2009
Controlling Class
Instance via Firebug
• Creating a class instance with
optional parameters
• Inserting custom instances into the
DOM
• Accessing the public API of a class
instance
• Class instances maintain state
Thursday, February 19, 2009
But what does the
DOM look like?
Thursday, February 19, 2009
Thursday, February 19, 2009
How is this
elegance possible?
Thursday, February 19, 2009
Constructors
Thursday, February 19, 2009
Overwrite Options
During
Thursday, February 19, 2009
Insert Anything.
Element#insert(anything);
Thursday, February 19, 2009
Programmatically
Create Elements
Thursday, February 19, 2009
Events
Use the DOM as a notification system for your
class.
Thursday, February 19, 2009
Standard DOM
Events
Thursday, February 19, 2009
Standard DOM
Events
Thursday, February 19, 2009
Standard DOM
Events
Function#bind(this)
Your best friend when using classes.
Allows referencing instance variables in an event listener.
Thursday, February 19, 2009
Custom Events Too
Thursday, February 19, 2009
Custom Events Too
Thursday, February 19, 2009
Custom Events Too
Thursday, February 19, 2009
Custom Events Too
Thursday, February 19, 2009
Custom Events Too
Thursday, February 19, 2009
AJAX
Everybody’s doing it.
Thursday, February 19, 2009
Thursday, February 19, 2009
Evaluate JSON
Thursday, February 19, 2009
Questions?
• http://github.com/camwest/
refresh-prototype-talk
• http://bigbangtechnology.com/blog
Thursday, February 19, 2009
0 comments
Post a comment