Forum: Ruby on Rails Unobtrusive Javascript in Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C4cd024191ff30fb901592e63d9ef820?d=identicon&s=25 DAZ (Guest)
on 2008-12-13 17:05
(Received via mailing list)
Hi everybody,

I love using rails, but one of my major problems with it has always
been how the helper methods create some really ugly inline javascript.

I've recently found jQuery after watching Ryans brilliant Railscast
about it (http://railscasts.com/episodes/136-jquery).

I think that jQuery is a great way to make Rails unobtrusive and it
has a really easy to pick up syntax.

The main problem is though that you can't use any of those nice helper
methods anymore!

Is anybody interested in helping me to get a project going to try and
set some best practice, code snippets to do common tasks or even
jQuery or Rails plugins that would help make unobtrusive JS just as
easy as the default JS in Rails? If anybody has already done any of
this then please let me know. Here is a wishlist to get started:

* Find an unobtrusive way of deleting things in a RESTful way
* Faking the PUT and DELETE verbs unobtrusively
* Adding an authenticity token to forms unobtrusively (the form_for
helper adds a bit of inline javascript)
* Which jQuery plugins are essential? Should they all be packaged up
as a Rails plugin that would work similar to <%
javascript_include_tag :defaults %>
* Easy drag and drop that plays nicely with the controller
* Sortable lists and sortable nested lists
* Inline editing
* Are there any settings that are needed (such as when Ryan sets this
up in the railscast)
jQuery.ajaxSetup({
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/
javascript")}
})
or the fact that you need something like the following before you can
use Ajax with authenticity tokens:
<%= javascript_tag "window._token = '#{form_authenticity_token}'" if
protect_against_forgery? %>


Hope this gets some discussion going ... I don't intend for this to
become a discussion about whether or not UJS is worth it or not. If
you are happy with the current inline stuff then please continue to
use it, but I know that a lot of people want UJS and this is an
attempt to make it as easy as possible for them to do that.

Looking forward to any thoughts....

cheers,

DAZ
This topic is locked and can not be replied to.