In the excellent book Editing Line-Items Efficiently, Dave Goodlad goes through his develpment process for using some XMLHttpRequest elements to streamline a Rails application.
Having done the same exercise some time ago, I have to say I was highly impressed with Dave's methodology and the 'clean-ness' of his design. I wrote up a little app to perform almost exactly the same function (editing users) with almost exactly the same UI (table view, click an edit button to replace text with form fields, and a save button), but I was far too heavily reliant on Javascript.
The JS was all nice and abstracted, but relied on some form naming conventions to properly munge the DOM objects, obviously less than ideal. Dave's example drives home the following points:
- You already have an excellent framework available in Rails
- Said framework is really nice at templating and HTML generation
- The JS to perform the request calls should be as simple as possible
Of course, this is only one way to do it, but I found it to be far superior to my initial foray in the same direction. Time to go download it and implement his methods myself, maybe throw in some error checking & timeout handling, just in case.
Don't try to do the heavy lifting in JavaScript, or even light lifting, keep it is an intermediary transport. Let the far superior middleware handle your lifting needs.
Post a comment