问题
do you know an alternative to jrails?
It's more or less outdated (uses jQuery 1.5 - now 1.7 is the current release).
Does anybody know an alternative?
Thanks
EDIT:
I know how to build the rails helper with jquery allone - but I like the rails helpers, so I dont want to use jquery allone (without jrails)
回答1:
Right now there's no real alternative. However, you can install jRails then upgrade the jQuery installation simply replacing the javascript files (except jrails.js) in the javascripts folder.
The only issue I'm aware of about jRails is that current version isn't compatible with Ruby 1.9.
回答2:
Having always used the Prototype helpers with Rails, I recently decided to move over to using JQuery. At first I looked at JRails, since it was a drop-in replacement and hence would require minimum effort.
BUT! After reading more about JQuery and playing around with it, it became apparent to me that the best way to use Rails and JQuery together is to handle it all yourself. This might sound like a more complicated, time consuming approach but it's honestly not! I see this approach as giving you two main benefits:
- All your Javascript can be unobtrusive -- this won't be the case with JRails
- You can use JQuery in
.js.erb
templates rather than using RJS templates, which gives you much finer control and is easier for front-end designers who are familiar with JQuery to get to grips with (the indirection of RJS, with it's Page object, is often confusing)
So, I recommend the first thing you do is watch the excellent JQuery Railscasts: http://railscasts.com/episodes/136-jquery. It's only a few minutes long and you'll be amazed at how easy and elegant it is to write AJAX code using JQuery and Rails.
You'll obviously need to get up to speed with JQuery too, but there are many excellent resources out there for this. JQuery is such an desirable skill these days, you'll be really thankful you took this approach.
回答3:
I was in the same position of looking for an alternative a couple months ago. I ended up writing my own jquery in .js.erb files, and I would recommend that. Javascript isn't nearly as painful when using jQuery.
回答4:
using Rails 2.3.5 and jQuery 1.4.2, I needed to add the {render :layout => false} option in format.js statement in the controller:
respond_to do |format|
format.js { render :layout => false }
end
Hope that Helps, Nelson
来源:https://stackoverflow.com/questions/1193119/jrails-alternative