$(function(){ var $frmCrimagify = $(".nested_crimagify_images"); if($frmCrimagify.find(".fieldset_crimagify_nested").length == 1){ setAttributesNames($frmCrimagify); }else if($frmCrimagify.find(".fieldset_crimagify_nested").length > 1) { $this = $frmCrimagify; var $fieldset = $frmCrimagify.find(".fieldset_crimagify_nested") for (var i = 0; i<$fieldset.length;i++){ var $new_fieldset = $($fieldset[i]); $new_fieldset.attr("id", "nested_"+i); $new_fieldset.attr("id","nested_" + i); $new_fieldset.find(".parent").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+i+'][parent]'); $new_fieldset.find(".parent_id").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+i+'][parent_id]'); $new_fieldset.find(".id_images").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+i+'][id_images]'); // $new_fieldset.find(".remove").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+i+'][_destroy]'); // $fieldset.find(".remove").removeAttr("id"); var imagesTemporal = $new_fieldset.find(".image_temporal"); for(var j = 0; j