about me

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.

Categories

jQuery helpers for Rails 3.0.0.beta

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.

4 Comments

Comment #1 by webPragmatist  on  02/08  at  07:42 PM

Checkin’ sum spellz…
no rly. FIRST!

Comment #2 by Sergio Rivas  on  02/13  at  02:51 PM

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?

Comment #3 by CodeOfficer  on  02/13  at  03:29 PM

@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

Comment #4 by Sergio Rivas  on  02/13  at  03:43 PM

Thanks! As you say:

I just add this line:

gem “jquery_helpers”

to Gemfile And Works!

Leave a comment?

Please use Pastie or Gist if you need to write code in your comments.

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?

Please enter the word you see in the image below:


RailsConf 2008 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.

recommend me!

Search

You Can Find Me

@ github.com
@ twitter.com
@ calendaraboutnothing

My Wishlists

@ Amazon.com

My Other Sites

Foundation's Edge, RJones Family, We're Not.com (only for staging), Ailee Jones (same as rjones for now)

Friends of Mine

Aaron, Barnaby, Brian, Chris, Dirk, Frank, Four, Justin, Matt, Mike, Monty, Paul, Sean, Travis

IRC Hangouts

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.