Why write lots of code to unpack an XML or a JSON response and act on it when
you can just move chunks of HTML around? Second, browser JavaScript, by its very nature, is
a slow and unreliable beast. The less work you can get away with, the more likely it is to work,
and the more responsive your application will be. There are, of course, many use cases in
which JSON or XML might be necessary, but on the whole you can get away with something
very simple??”so always strive for that.
Summary
In implementing the sidebar feature in this chapter I hopefully demonstrated that progressive
enhancement is no more difficult than old-fashioned, obtrusive scripting. Especially
with tools such as Low Pro, you can get powerful results without the expense of breaking
browser functionality, rendering your application inaccessible or useless to users on mobile
browsers or behind firewalls. There??™s a common misconception that progressive enhancement
is more effort than obtrusive techniques, and even that progressive enhancement is
not possible for most applications, but I??™m sure you??™ll find that this is simply not the case.
Progressive enhancement should be your default approach to DOM scripting.
Source Code
Rails generates a large amount of boilerplate code to support your application, but for this
project only a few files are actually relevant. Following are the complete listings of those files
for your reference.
Pages:
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291