Update the view
Add search form and handle the submit using jquery
1: <%=form_for :searchP ,:html => { :id => "Start_Search_Form" } do |f| %>2: <fieldset>3: <legend>Search for operator</legend>
4: <%= f.label :pharse %>5: <%= f.text_field :pharse,:size=>"45",:class=>"round",:id=>"pharse" %><br/>6: <p><%= button_to "Start Search",{:class=>"SearchButton"} %></p>7: </fieldset>8:9: <%end%>10:11: <script src="../../Scripts/jquery-1.8.2.js"></script>
12: <script>13:14: $('#Start_Search_Form').submit(function() {
15: var valuesToSubmit = $(this).serialize();16:17: alert (valuesToSubmit);
18:19: $.ajax({20: url: $(this).attr('StartSearch'), //sumbits it to the given url of the form21: data: valuesToSubmit,22: dataType: "JSON" // you want a difference between normal and ajax-calls, and json is standard23: }).success(function(json){
24: alert (json);
25: });26: return false; // prevents normal behaviour27: });28:29: </script>
note the changing of the rails form id
Resources
אין תגובות:
הוסף רשומת תגובה