Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Supporting button[data-remote] as replacement of button_to helper #308

merged 1 commit into from May 29, 2013


None yet
3 participants

In some cases we want to send data via AJAX with appropriate HTTP method (POST/PUT/DELETE).

We have two possibilities to reach this:

  1. use "a" tag (link_to helper) with data-remote and data-method
  2. use "button_to" helper.

In the first case the trouble is that user can do middle-click, then will be opened new tab in browser with correct url, but with wrong HTTP method (GET instead POST/PUT/DELETE).

In the second case the trouble is that additional markup will be generated (form, div, input...).

So this pull request will add support "button" tag with "data-remote" attribute, which solve issues with "link" and "button_to" approaches.
Also "button" tag have great ability to customization, because it can have inline html markup as opposed to "input" tag.


JangoSteve commented May 29, 2013

This looks good to me. Thanks for the test.

The only comment I have is that the default method should be GET instead of POST. But I'll change this after I pull it in.

@JangoSteve JangoSteve merged commit c304620 into rails:master May 29, 2013


boud instead of bound

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment