sscirrus
sscirrus

Reputation: 56749

Programming style - Anything wrong with :remote & .js.erb being the main approach?

For some 'minor' actions in my site, I'm using remote instead of standard HTML requests. My current remote technique is like this:

  1. Use form_for or form_tag with :remote => true.
  2. In the controller action, do:

    respond_to do |format|
      format.js
    end
    
  3. Then create a .js.erb file that loads a partial / creates a flash message / highlights parts of the page, etc.

I want to understand the implications of my approach because I don't want my own ignorance to lead to problems I don't know about.

  1. Are there any accessibility problems with the above, i.e. are there people who wouldn't be able to use my code above due to their browser / disability / something else?
  2. Is the above the 'current' way to do things in Rails, or can you point me to something that is better?
  3. Are there any issues with security or performance that could be improved by doing it another way?

Upvotes: 1

Views: 67

Answers (1)

apneadiving
apneadiving

Reputation: 115541

  1. It doesn't lead to more browser issues than usual js

  2. I'd say it's the current way for low traffic or few actions (like admin reserved area)

  3. Using this technique leads to more server work than basic ajax returning json handled fully client-side.

Upvotes: 1

Related Questions