Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jquery-rest

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-rest

  • 0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

jQuery REST

Add shortcuts to make PUT and DELETE AJAX requests:

$.put('/posts/1', { title: 'New' }, function(message) {
    alert('Saved. ' + message)
})

$.del('/posts/1', function(message) {
    alert('Deleted. ' + message)
})

Because some browsers and firewalls have problems with PUT and DELETE requests, shortcuts create POST request with X-HTTP-Method-Override header with correct method name.

All Rack frameworks (Ruby on Rails, Sinatra) support this override. For plain Rack app you need to use Rack::MethodOverride middleware.

Shorcuts have same arguments as $.post (url, data, callback, dataType), so you can set response type on last argument.

They just shortcuts under $.ajax, so they return $.Deferred object:

$.delete('/posts/1').
    success(function() { alert('Deleted') }).
    error(function() { alert('Error') })

Install

Rails 3.1

In Rails 3.1 (or another project with Sprockets 2) just add jquery-rest to Gemfile:

gem 'jquery-rest'

and add require to app/assets/javascripts/application.js.coffee:

#= require "jquery.rest"

Jammit

If you use Jammit or another package manager just copy lib/jquery.rest.js to public/javascripts/lib in your project and add library to config/assets.yml:

javascripts:
  application:
    - public/javascripts/lib/jquery.rest.js

Other

If you didn’t use Rails 3.1 or assets packaging manager you can use already minimized version of library at lib/jquery.rest.min.js.

Contributing

To run project tests and minimize source you must have Ruby and Bundler. For example, on Ubuntu:

sudo apt-get install ruby rubygems
sudo gem install bundler

Next you need install Jasmine, UglifyJS and other dependencies by Bundler. Run in project root:

bundle install --path=.bundle

That’s all. To run tests start server and open http://localhost:8888/:

bundle exec rake server

Before commit minimize project source:

bundle exec rake min

FAQs

Package last updated on 01 Jun 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc