I use jquery repeater in my project. When I try set default value for input type date return error:
jquery.repeater.js:688 Uncaught TypeError: Cannot read property 'set' of undefined
Form code:
<form action="" class="repeater" enctype="multipart/form-data">
<div data-repeater-list="users">
<div data-repeater-item>
<input type="text" name="name"/>
<input type="email" name="email"/>
<select name="sex">
<option value="0" selected>Male</option>
<option value="1">Female</option>
</select>
<input type="date" name="birthday"/>
<input data-repeater-delete type="button" value="Delete"/>
</div>
</div>
<input id="add" data-repeater-create type="button" value="Add User"/>
</form>
Javascript code:
$(document).ready(function () {
'use strict';
$('.repeater').repeater({
defaultValues: {
'name': 'User',
'email': '[email protected]',
'sex': '0',
'birthday': "1990-09-10"
},
show: function () {
$(this).slideDown();
},
hide: function (deleteElement) {
if(confirm('Are you sure you want to delete this element?')) {
$(this).slideUp(deleteElement);
}
},
ready: function (setIndexes) {
}
});
$('#add').on('click', function(e){
var users = $('.repeater').repeaterVal();
console.log(users);
});
});
When I don't set default value then I can't get all fields values.
For me I did it the old fashioned way using JQuery