-
Notifications
You must be signed in to change notification settings - Fork 191
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
Using setList causes repeater to add 2 data-repeater-items at a time instead of 1 #48
Comments
Okay, It appears for some reason the click event for [data-repeater-create] is fired twice so it adds 2 additional repeater items per click of the "add" button. I am not sure why this happens only when setList is used. Could be related to "event bubbling" due to how setList works. In any case I have a solution that fixes this issue for me. It shouldn't break anything but I haven't done any exhaustive testing. In jquery.repeater.js we have to make the following changes: Before:
After: + $filterNested($self.find('[data-repeater-create]'), fig.repeaters).click(function (event) {
addItem();
+ event.stopImmediatePropagation();
}); |
again, thanks. |
Thank you, you save my life 💃 |
DIG DOWN THE PROBLEMI found the issue happened when we do something like below: // Initiate repeater
$('.my-repeater').repeater({
// whatever
});
// Set the data
var my_repeater = $('.my-repeater').repeater();
my_repeater.setList([
{ 'input_name': 'foo-1' },
{ 'input_name': 'foo-2' }
]); PROBLEMThe problem is on this line: SOLUTIONI found the correct method of calling // Initiate the repeater and set a variable
var my_repeater = $('.my-repeater').repeater({
// whatever
});
// Set the data on the previous repeater on edit mode
if( true === edit_mode ) {
my_repeater.setList([
{ 'input_name': 'foo-1' },
{ 'input_name': 'foo-2' }
]);
}
|
var repeater = $('.repeater').repeater(); |
I used nested so i am not getting the value |
Is this code |
how do you set a variable here
how do you set a new variable here please help me |
Hello,
I've noticed that when I use setList to load my form elements subsequently adding a repeater item via the "add" button (data-repeater-create) creates 2 additional items instead of one.
This only happens when I use setList. Any ideas what could be causing this to happen?
Thanks.
The text was updated successfully, but these errors were encountered: