No description or website provided.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
ruby-jquery.gemspec

README.md

ruby-jquery BuildStatus

ruby-jquery is a jQuery expression generator.

Synopsis

require 'jquery'

jQuery()                                       #=> jQuery()
jQuery('a')                                    #=> jQuery("a")
jQuery(:document)                              #=> jQuery(document)
jQuery('a').text()                             #=> jQuery("a").text()
jQuery('a').text('aaa')                        #=> jQuery("a").text("aaa")
jQuery('a').foo(['a', 'b'])                    #=> jQuery("a").foo(["a","b"])
jQuery('a').foo({'a' => 'b'})                  #=> jQuery("a").foo({"a":"b"})
jQuery('a').click(->(f) { f.e 'return true' }) #=> jQuery("a").click(function (e) { return true })

jQuery('#content').show().on('click', 'a', ->(f) { f.e 'return true' })
#=> jQuery("#content").show().on("click","a",function (e) { return true })

With Selenium Driver

You can use this library with Selenium Driver for Ruby like below:

driver.execute_script(
  "return " << jQuery('#content a').attr('href')
)

Installation

Add this line to your application's Gemfile:

gem 'ruby-jquery'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruby-jquery

TODO

  • Support property access (e.g. jQuery.ajax(...) and jQuery('a').length). But can I do it with Ruby?

See Also

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request