Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // create.js.erb
- $("#add_item_form").replaceWith("<%= escape_javascript(render(:partial => 'designs/items_form')) %>");
- // application.js
- jQuery.fn.submitAjaxItemForm = function() {
- this.submit(function() {
- $.post(this.action, $(this).serialize(), null, "script");
- return false;
- })
- return this;
- };
- $(document).ready(function() {
- $("#add_item_form").submitAjaxItemForm();
- });
- // designs/_items_form.html.erb
- <% form_for [@design, @design_component], :html => {:id => "add_item_form" } do |f| %>
- <% unless @item_container.blank? -%>
- <p class="options-choose" id="item_container_label"><%= @item_container.label %>:</p>
- <% end -%>
- <% @items.each_with_index do |item, i| -%>
- <% line = i % 2 == 1 ? "odd" : "even" -%>
- <% content_tag :p, :class => line do %>
- <%= radio_button 'design_component', 'item_id', item.id %>
- <%= item.label %>
- <% end -%>
- <% end %>
- <%= submit_tag "Next" %>
- <p class="options-choose" id="ajax_msg"> </p>
- <% end %>
Add Comment
Please, Sign In to add comment