Skip to content
This repository
Browse code

Initial version - quick brain dump

  • Loading branch information...
commit a40a720b0ab595f5043058989b8820411fd066a7 1 parent 01064e2
Peter Szinek authored May 16, 2009
94  railties/guides/source/ajax_on_rails.textile
Source Rendered
... ...
@@ -0,0 +1,94 @@
  1
+h2. AJAX on Rails
  2
+
  3
+This guide covers the built-in Ajax/Javascript functionality of Rails (and more); it will enable you to create rich and dynamic AJAX applications with ease! We will cover the following topics:
  4
+
  5
+* Quick introduction to AJAX and related technologies
  6
+* Handling Javascript the Rails way: Rails helpers, RJS, Prototype and script.aculo.us  
  7
+* Testing Javascript functionality
  8
+* Becoming an Ajax Master on Rails: Plugins, Best Practices, Tips and Tricks
  9
+
  10
+endprologue.
  11
+
  12
+h3. Hello AJAX - a Quick Intro
  13
+
  14
+If you are a 'show me the code' type of person, you might want to skip this part and jump to the RJS section right away. However, I would really recommend to read it - you'll need the basics of DOM, http requests and other topics discussed here to really understand Ajax on Rails.
  15
+
  16
+h4. Asynchronous Javascript + XML
  17
+
  18
+Basic terminology, new style of creating web apps
  19
+
  20
+h4. The DOM
  21
+
  22
+basics of the DOM, how is it built, properties, features, why is it central to AJAX
  23
+
  24
+h4. Standard HTML communication vs AJAX
  25
+
  26
+How do 'standard' and AJAX requests differ, why does this matter for understanding AJAX on Rails (tie in for *_remote helpers, the next section)
  27
+
  28
+
  29
+
  30
+
  31
+
  32
+
  33
+h3. Built-in Rails Helpers 
  34
+
  35
+Mostly a reference to standard JS helpers like link_to_remote, remote_form_for etc + some explanation
  36
+
  37
+
  38
+
  39
+h3. Responding to AJAX the Rails way: RJS
  40
+
  41
+In the last section we sent some AJAX requests to the server; now we need to respond, and the standard Rails way to this is using RJS; RJS intro, function reference
  42
+
  43
+
  44
+
  45
+h3. I Want my Yellow Thingy: Prototype and Script.aculo.us
  46
+
  47
+Walk through prototype and script.aculo.us, most important functionality, method reference etc.
  48
+
  49
+
  50
+
  51
+h3. Testing Javascript
  52
+
  53
+Javascript testing reminds me the definition of the world 'classic' by Mark Twain: "A classic is something that everybody wants to have read and nobody wants to read." It's similar with Javascript testing: everyone would like to have it, yet it's not done by too much developers as it is tedious, complicated, there is a proliferation of tools and no consensus/accepted best practices, but we will nevertheless take a stab at it:
  54
+
  55
+* (Fire)Watir
  56
+* Selenium
  57
+* Celerity/Culerity
  58
+* Cucumber+Webrat
  59
+* Mention stuff like screw.unit/jsSpec
  60
+
  61
+Note to self: check out the RailsConf JS testing video
  62
+
  63
+h3. Useful Plugins
  64
+
  65
+This was in the ticket description, but at the moment I don't really have clue what to add here, so please tell me
  66
+
  67
+
  68
+
  69
+h3. Tips and Tricks
  70
+
  71
+* Unobtrusive Javascript (Prototype events, maybe the jQuery way (esp. jQeury.live()))
  72
+
  73
+* Minimize communication with the server - there does not have to be a communication at all!
  74
+** If you absolutely don't have to, don't use Rails observers
  75
+** Cache stuff on the client side, e.g. with auto-complete
  76
+
  77
+* Using AJAX to load stuff asynchronously
  78
+** To avoid page blocking
  79
+** Tricking page caching 
  80
+*** inserting user-specific info into a cached page
  81
+*** anti-CSFR bit
  82
+
  83
+* Jumping to the top? Try event.stopPropagation
  84
+
  85
+* Performance 
  86
+** pack your javascript (minify, asset packager)
  87
+** require your JS at the end of the file
  88
+** other perf tricks and optimization
  89
+
  90
+* Don't overuse AJAX
  91
+** Usability first, cool effects second
  92
+** situations where AJAX is discouraged
  93
+
  94
+* Last but not least: Javascript is your friend :)

0 notes on commit a40a720

Please sign in to comment.
Something went wrong with that request. Please try again.