I'm a 35'ish year old web application developer from South Portland, Maine. I love meeting fellow techies, drop me a line if you want to talk shop.
Posted on 02/08/2010 at 06:58 PM
I’ve just ported the unobtrusive javascript helpers in Rails 3 from Prototype to jQuery-1.4.1, but I haven’t tested it to work with earlier versions of jQuery yet. Let me know if you find this useful or have any issues installing the gem.
For those that don’t know, Rails 3 now makes use of HTML5 custom data attributes on the DOM instead of generating javascript inline when using it’s built in javascript helpers. If you’re not planning to use HTML5 in your app, you might benefit from another plugin I wrote called js-data-helper.
Thanks to @technicalpickles for helping me package this up as a gem.
The code is on Github.
http://github.com/CodeOfficer/jquery-helpers-for-rails3
The gem is on Gemcutter
http://gemcutter.org/gems/jquery_helpers
Install:
(sudo) gem install jquery_helpers
Usage:
rails generate jquery_helpers [options]
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Supress status output
-s, [--skip] # Skip files that already exist
Description:
A port of the unobtrusive Prototype helpers in Rails 3 to jQuery
Example:
./script/generate jquery_helpers
This will create:
public/javascripts/jquery.rails.js
public/javascripts/jquery.rails.min.js
Don’t forget to include ‘jquery.rails.js’ in your layout along with jQuery.
I have installed the gem with
gem install jquery_helpers
When I go to generate the helpers, its doesn’t work…
rails generate jquery_helpers
$ Could not find generator jquery_helpers.
Can you help me?
@sergio, make sure you bundle your gems first. Your rails 3 app wont be able to use the generator of this gem until you’ve bundled it. Use:
bundle pack
Thanks! As you say:
I just add this line:
gem “jquery_helpers”
to Gemfile And Works!
Often times I will release code for free or go that extra distance to help others online. If my skills were useful to you, please consider a small donation. Thank you very much.
@ github.com
@ twitter.com
@ calendaraboutnothing
Foundation's Edge, RJones Family, We're Not.com (only for staging), Ailee Jones (same as rjones for now)
Aaron, Barnaby, Brian, Chris, Dirk, Frank, Four, Justin, Matt, Mike, Monty, Paul, Sean, Travis
I can usually be found lounging on irc.freenode.net while I work, on the following channels: #fauna, #github, #hello-heroku, #jquery, #passenger, #ruby, #rubyonrails, #slicehost, #sproutcore, #textmate, #werenot.
Checkin’ sum spellz…
no rly. FIRST!