Reputation: 6269
How you can see i have an link_to with an empty parameter :street :
<%= link_to "#{g.name}", icd_test_path(g, :street => "...."), remote: true %>
I would like to have the content of this a-tag with the id => "form" as param :street
<a id="form">Boulevard</a>
How can i make this? Is there any solution with jquery?
I suspect my link_to should look something like this:
:street => $(#form).html()
Upvotes: 0
Views: 1442
Reputation: 1303
You can do this in rails
itself, try this:
<%= link_to g.name, icd_test_path(g, :street => g.name), remote: true %>
If your requirement is different the please comment, I will try to get you the solution.
Through Jquery you can try this code:
Your link can be like:
<%= link_to g.name, icd_test_path(g), remote: true %>
Then add following javascript code:
$(function() {
var href = $('#form').attr('href');
var queryString = '?street=' + encodeURIComponent($('#form').text());
$('#form').attr('href', href + queryString );
});
Upvotes: 2