Giter Site home page Giter Site logo

restfulizerjs's Introduction

RestfulizerJs

_Native POST support and hidden "method" input support for PUT/DELETE

A simple jQuery plugin for changing the http method (POST/PUT/DELETE) of a simple html link or button.

How to use

1: Add the jquery.restfulizer.js file into your project including jQuery.

  <script type="text/javascript" src="js/jquery.restfulizer.js"></script>

2: Use the jQuery method restfulizer() on any link you want to customize the method :

<a href="/user/3" data-method="DELETE" class="rest">link</a>
$(".rest").restfulizer();

Advanced usage

You can also POST links with parameters (and also automatically setup the POST method) :

<a href="/user/create?name=John&age=18&[email protected]" class="rest-post">link</a>
$(".rest-post").restfulizer({
        parse: true,
        method: "POST"
});

Full options usage

$(".rest").restfulizer({
        parse: true, // Parse the URL parameters (allow to send them to POST)
        method: "PUT", // The method (POST is native but PUT and DELETE will be simulated with a hidden input called "_method", this solution is handled by many PHP frameworks)
        target: "example.html?specified=yes" // The target (usefull for making non link clickable)
});

restfulizerjs's People

Contributors

ifnotfr avatar verto avatar vluzrmos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

restfulizerjs's Issues

Fragment support was dropped with last commit

With the last commit, if the restfulized URL contains a fragment (#), it will remain appended to the last parameter.

For example, the URL script.php?page=1&val=1#frag will be converted to a form having <input type="hidden" value="1#frag" name="val">.

Add package to npm repository

Your package is not yet available in npmjs.org. It would be nice if you could add it there so people don't have to use npm as well as bower to manage their dependencies :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.