Sha256: 9edad507a9737380d801d12f8c27e43d2e0c76e9e2e71860599dfdbc8d1dfd91
Contents?: true
Size: 1.6 KB
Versions: 13
Compression:
Stored size: 1.6 KB
Contents
<% content_for "modal_for_#{attribute}" do %> <% new_page_title = Typus::I18n.t("Add %{resource}", :resource => related.model_name.human.titleize) %> <div id="modal-from-dom-<%= attribute_id %>" class="modal hide fade"> <div class="modal-header"> <a class="close" data-dismiss="modal">×</a> <h3><%= new_page_title %></h3> </div> <div class="modal-body"></div> <div class="modal-footer"> <% html_options = { :id => "modal-form-submit", :class => "btn btn-primary" } %> <%= link_to Typus::I18n.t("Save"), { :anchor => "", :_continue => true }, html_options %> </div> <script> <%= object_id = "new_#{related.model_name.to_s.downcase}" %> $('#modal-form-submit').click(function(e){ e.preventDefault(); $('#<%= object_id %>').submit(function() { // Get the action url: var action; action = $('#<%= object_id %>').attr('action'); $.post(action, $(this).serialize(), function(data){}) .success(function(data, text, xhr) { $('.modal-body').html(data); var option = new Option($("#_label").attr("value"), $("#_id").attr("value"), true, true); parent.$("#<%= attribute_id %>").prepend(option); $("#modal-from-dom-<%= attribute_id %>").modal('hide'); }) .error(function(request, status, error) { $('.modal-body').html(request.responseText); }); return false; }); $('#<%= related.model_name.to_s.downcase %>').submit(); return false; }); </script> </div> <% end %>
Version data entries
13 entries across 13 versions & 1 rubygems