I'm using the following jquery plugin https://github.com/DubFriend/jquery.repeater to create repeatable input fields into a form. I've also added support for re-ordering of the elements through the jquery sortable plugin. Everything is working fine except the indexing of the repeatable elements is messed up.
By reading the documentation of the repeater plugin, I see there's a way to reset the index https://github.com/DubFriend/jquery.repeater/issues/9 but I'm unable to understand how to trigger the functionality after the drag and drop. Can anybody suggest me how to do it?
This is my sortable code
jQuery(".repeater-table").sortable({
axis: "y",
cursor: 'pointer',
opacity: 0.5,
placeholder: "row-dragging",
delay: 150,
handle: ".sort-option",
update: function(event, ui) {
// stuff to do on sorting update.
}
}).disableSelection();
And this is the repeater code.
jQuery('.wpumcf-field-repeater-options').repeater({
show: function() {
jQuery(this).slideDown();
jQuery('.repeater-wrapper').animate({
scrollTop: jQuery('.repeater-table').height()
}, 300);
},
hide: function(deleteElement) {
if (confirm(wpum_admin_js.confirm)) {
jQuery(this).slideUp(deleteElement);
}
},
ready: function(setIndexes) {
$dragAndDrop.on('drop', setIndexes);
},
isFirstItemUndeletable: true
});
Does anybody have any idea how to trigger the reset?