DubFriend / jquery.repeater

Create a repeatable group of input elements
MIT License
391 stars 192 forks source link

Set constant name for some inputs #74

Open rhnkyr opened 7 years ago

rhnkyr commented 7 years ago

Hi guys,

i want to upload multiple files via c# IEnumerable<HttpPostedFileBase> and try to fix input:file name to listImages. My code like this :

`var id = 0; $(".mt-repeater").each(function(){ $(this).repeater({ show: function () { $(this).slideDown(); $(this).find("textarea").attr("id", "mce"+id); $(".mt-repeater").find('input:file').attr('name', "listImages"); tinymce.EditorManager.execCommand("mceAddEditor", true, "mce"+id); id++; },

                    hide: function (deleteElement) {

                        alertify.confirm('XXXXXX',
                            'XXXXXXXX',
                            function() {
                                $(".mt-repeater").find('input:file').attr('name', "listImages");
                                $(this).slideUp(deleteElement);
                            },
                            null);

                    },
                    ready : function() {
                        $(".mt-repeater").find('input:file').attr('name', "listImages");
                    },
                    isFirstItemUndeletable: true

                });
            });`

show works ok like this but when i delete a repeater row my first file input name changes to listElements[0][listImages]

How can prevent it or is there any proper solution for that.

Thanks in advance. Cheers.