From 38117627957f436daa52147478c522ba948b89c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Phillipp=20R=C3=B6ll?=
Date: Mon, 18 Feb 2013 12:55:22 +0100
Subject: [PATCH] Adds data-params handling for handleMethod. This allows the
link_to handler with e.g. method: "post" to add post fields from the a-tags
data-params attribute to the form.
---
src/rails.js | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/rails.js b/src/rails.js
index df9dc862..e5b2f1cc 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -186,6 +186,7 @@
var href = rails.href(link),
method = link.data('method'),
target = link.attr('target'),
+ params = link.data('params'),
csrf_token = $('meta[name=csrf-token]').attr('content'),
csrf_param = $('meta[name=csrf-param]').attr('content'),
form = $(''),
@@ -194,6 +195,12 @@
if (csrf_param !== undefined && csrf_token !== undefined) {
metadata_input += '';
}
+
+ if(params) {
+ for(key in params) {
+ metadata_input += '';
+ }
+ }
if (target) { form.attr('target', target); }