It's me the big rails newbie. I have another problem.
This is my partial for _care_point.html.erb
<div id='<%=dom_id(care_point) %>' class='draggable node_chin'>
<div id=<%="node_#{care_point.id}" %> class='node'><%= care_point.body %>
</div>
<textarea class='node_input'><%= care_point.body %></textarea>
<%= link_to 'Close', [care_map, care_point], :method => :post, :remote => true, :class => 'close' %>
<%= link_to 'Delete', [care_map, care_point], :confirm => "Are you sure?", :method => :delete, :remote => true, :class => 'delete' %>
</div>
When I click the Close link the request is sent to the server as expected. All the fields are null though. How do I make sure that my model object is kept updated before it is sent to the server? Do I have to use the form functionality or can I just update it with Javascript somehow?
Cheers
There is no reason not to use forms. Just enclose your fields into a form and add a submit button.
<%= form_for [care_map, care_point], :remote => true do |f| %>
<%= f.text_area :body %>
<%= f.submit "Close" %>
<% end %>
If you really want Close link instead of button, you can use javascript to override it's click event and send a form via Ajax.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.