jquery.repeater
jquery.repeater copied to clipboard
Improve documentation on hide elements
The README show an example of the hide
callback which is optional
hide: function (deleteElement) {
if(confirm('Are you sure you want to delete this element?')) {
$(this).slideUp(deleteElement);
}
},
But the jQuery slideUp function doesn't actually delete the DOM element and the $('.repeater').repeaterVal();
method get a wrong dataset, with the deleted data.
The better approach should use the $.remove
.
In order to keep the slideUp animation, the example should be:
hide: function (deleteElement) {
if(confirm('Are you sure you want to delete this element?')) {
$(this).slideUp(deleteElement, function() {
$(this).remove();
});
}
},
@viniciusbig , did you faced a problem that values of detected items was still there? #141 I have the same kind of issue i think,
@viniciusbig but the index of input array name only gets automatically resorted when using exactly $(this).slideUp(deleteElement);
and I don't know why
@viniciusbig but the index of input array name only gets automatically resorted when using exactly
$(this).slideUp(deleteElement);
and I don't know why
I'm having the same issue as OP.
However I'm also manually renaming the inputs anyway to be compatible with my the form processor being used.
jQuery example:
hide: function (deleteElement) {
$(this).slideUp(deleteElement, function() {
$(this).remove();
$('.item').each(function(i) {
$(this).attr('name', 'item: ' + (i+1));
});
});
},