Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to get the repeater values but it return an Uncaught TypeError: parsed[0] is undefined #177

Closed
AbdelazizLafqui opened this issue May 4, 2023 · 3 comments

Comments

@AbdelazizLafqui
Copy link

AbdelazizLafqui commented May 4, 2023

That's my repeater

<form class="repeater" id="kt_repeater">
                                <div data-repeater-list="group-a" class="col-lg-12">
                                    <div data-repeater-item="item-a" class="form-group row align-items-center">
                                        <div class="col-md-4">
                                            <label>Projects :</label>
                                            <select class="custom-select" data-kt-repeater="select2" data-placeholder="Select a projects">
                                                <option selected>Choose...</option>
                                            </select>
                                        </div>
                                        <div class="col-md-5">
                                            <label>Duration</label>
                                            <div class="input-group timepicker">
                                                <input class="form-control" id="kt_timepicker_1_validate" placeholder="Enter Duration"/>
                                                <div class="input-group-append">
                                                    <span class="input-group-text"><i class="la la-clock-o"></i></span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-2 align-middle text-right mt-9">
                                            <a href="javascript:;" data-repeater-delete="" class="btn btn-sm font-weight-bolder btn-light-danger">
                                                <i class="la la-trash-o"></i> 
                                            </a>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group row ml-0">
                                    <div class="col-lg-1 mr-10 h-100 text-left">
                                        <a href="javascript:;" data-repeater-create class="btn btn-sm font-weight-bolder btn-light-primary">
                                            Add
                                        </a>
                                    </div>
                                    <div class="col-lg-6 h-100">
                                        <a href="javascript:;" id="addRemainingDuration" class="btn btn-sm font-weight-bolder btn-light-primary">
                                            Add Remaining duration
                                        </a>
                                    </div>
                                    <div class="col-lg-3 text-right">
                                        <a href="javascript:;" id="saveRepeaterValuesButton" class="btn btn-sm font-weight-bolder btn-primary">
                                            Save
                                        </a>
                                    </div>
                                </div>
                            </form>
@AbdelazizLafqui
Copy link
Author

AbdelazizLafqui commented May 4, 2023

and that's repeater Jquery

var REPEATER = null;
            var KTFormRepeater = function() {
                var demo1 = function() {
                REPEATER = $('#kt_repeater').repeater({
                        initEmpty: true,
                        show: function() {
                            updateRepeaterItem($(this));
                        },
                        hide: function(deleteElement) {
                            $(this).slideUp(deleteElement);
                        },
                   })
                }
                return {
                    init: function() {
                        demo1();
                    }
                };
            }();

@AbdelazizLafqui
Copy link
Author

AbdelazizLafqui commented May 4, 2023

and that's how I'm trying to retrieve the values :

  jQuery(document).ready(function() {
                $('#saveRepeaterValuesButton').bind("click",
                    function() {
                        var data = REPEATER.repeaterVal();
                        console.log(data);
                    });
            });

@AbdelazizLafqui
Copy link
Author

AbdelazizLafqui commented May 10, 2023

I didn't looked up the repeaterVal implementation to understand how the function works, my issue is input fields implemetation was wrong.
I fixed it by adding name and type to input fields.
for the select :

<select class="custom-select" name="repeaterselectname" id="projectsselection" data-kt-repeater="select2" data-placeholder="select a projects">

and for the date field :

<input class="form-control" name="text-input" type="text" id="kt_timepicker_1_validate" placeholder="Enter Duration" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant