Do not use RJS-like techniques
homakov.blogspot.ru
homakov.blogspot.ru
See also: Data In, Garbage Out (http://glyph.twistedmatrix.com/2008/06/data-in-garbage-out.h...)
It's a matter of continuing puzzlement to me that, despite the fact that more robust and better-abstracted methods of producing output exist, the dominant paradigm in web development is to concatenate strings together and hope.
But it's worse than that: many people actively reject better methods on the basis that, as I've heard it expressed over and over, you "should" be able to just write HTML, ipse dixit. There's active resistance to improving this awful situation.
I don't understand it. I wish I did.
$('<div id="' + identifier + '">' + some_text + '</div>');
If so, consider doing: $('<div>').attr('id', identifier).text(some_text);
which handles escaping correctly for you.Or equivalent in your preferred JS framework or lack of framework.
Regarding #1; AJAX updates are incredibly easy (see the Railscast for review http://railscasts.com/episodes/136-jquery-ajax-revised?view=...). In fact, most of the Backbone BS that people are doing now days could be much more easily accomplished with a simple form_for (:remote => true) with a simple rjs response.
This author appears to have lost the simplicity in it's approach. Review the Railscast and this video of DHH showing off the new Basecamp (http://www.youtube.com/watch?v=FkLVl3gpJP4) and maybe you'll reconsider.
1 AJAX updates are easy, right. w/o RJS as well
i don't describe my approach because my approach is different — i wrote a post about other websites' approach (RJS is used in the wild)
Executing JavaScript code sent from the server requires your JS objects to be in the global scope. Returning JSON (on the other hand) allows you to keep your objects and logic inside a closure.
If both the requester of the AJAX call and the receiver are in the same closure, there's no need for those objects to be globally accessible.
Client should not trust server as well. If server goes mad it still can be not compromising client-side (unless app was completely hacked and HTML was changed)
Even though it had all these issues, it was simpler for developers. Now it's deprecated.
What are the best in class techniques for developers eager to do secure yet highly interactive apps in Rails today?
Please make useful suggestions and cut down on specious remarks. RJS is not in use for a long time. This article did not even merit the first page, except it's a slow weekend.
Way to go downvoting for that, too - shows real depth. I shall not try make you "understand" the existence of this fast-expanding space.