Sha256: 2814b56a966eac9239e6306c45b3fed3f6851a03cda5b0b3fc0a9303793edcc4
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
= simple_form_for(model_object, :url => url, :html => {:class => 'formframe container-fluid'}) do |f| = render "carnival/shared/form/inner_form", button: button, model_object: model_object, model_presenter: model_presenter, :url => url, :action => action, :f => f .submit_button = f.submit button, disable_with: t('please_wait'), class: 'submit' :javascript var nestedForms = {}; $(document).ready(function(){ nestedForm = $(".nested-form-list .form-new-association").each(function(index, element){ nestedForms[getFormName(element)] = element; element.remove(); }); }); function createNewForm(selector, form){ newForm = $(nestedForms[form]).clone().wrap("<div>").parent().html(); var last_index = $(selector + " li").length newForm = newForm.replace(/([_a-zA-Z]+_attributes_)\d+(_[a-zA-Z]+)/g, "$1" + last_index + "$2"); newForm = newForm.replace(/([_a-zA-Z]+\[[_a-zA-Z]+_attributes\]\[)\d+(\]\[[a-zA-Z]+\])/g, "$1" + last_index + "$2"); $(selector).append(newForm); } function getFormName(element){ var classes = $(element).parent().attr("class").split(" "); classes.splice(classes.indexOf("nested-form-list"), 1); return classes[0]; } function removeNestedFormElement(element){ $(element).parent().parent().hide(); $(element).parent().parent().find(".destroy").val(true); } function toggleNestedForm(element){ $(element).parent().parent().find("ul.nested-form-list").toggle(); if($(element).text() == "#{t('close')}") $(element).text("#{t('open')}"); else $(element).text("#{t('close')}"); }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
carnival-0.0.38 | app/views/carnival/shared/form/_form.html.haml |
carnival-0.0.37 | app/views/carnival/shared/form/_form.html.haml |