In this session we'll take a hands on approach to building reusable and scaleable front end code. We walk through building a modern web application UI using microformats, gracefully degrading CSS3 and Javascript closures. Finally, we'll see how the same code can be used throughout an application with little modification.
29. THE CASE FOR UJS
<a href="#" onclick="new
Ajax.Updater('foo', 'http://
• Very painful to test strangelove.local/tags/1',
{asynchronous:true,
evalScripts:true,
• Impossible to reuse parameters:'authenticity_token=' +
encodeURIComponent('xXnuBemPMRAar/
• Hard to debug EUBB9GbcXD/
+HUhOaUxoAnkm5KSy8=')}); return
false;">Zip</a>
30. WRITING REUSABLE
JAVASCRIPT
var Photor = {};
Photor.Tags = (function($){
return {
init: function(){
• Namespaced
}
}
})(jQuery);
• Public vs Private Methods
$(document).ready(function(){
Photor.Tags.init();
});