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

bugfix: List editor behaves wrongly when calling setValue() more than once #372

Closed
wants to merge 1 commit into from

Conversation

gerardobort
Copy link

It was accumulating elements on each call, apart of that, the render() method also wasn't refreshing the DOM after the first call.

The way to reproduce is simple..

// given an exisiting and already rendered form...
form.setValue({ a_list_propery: ['a', 'b'] });

The form was not only accumulating elements, but also not refreshing the view.

I hope this could reach the trunk,
Thanks,

…lements on each call, apart of that, the render() method wasnt refreshing the DOM after the first call (called after by setValue)
@bpardee
Copy link
Contributor

bpardee commented Apr 2, 2014

Same as #282

//In case of there was a pre-existing element already placed in the DOM, then update it
if (domReferencedElement) {
$(domReferencedElement).replaceWith(this.el);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this section seems unnecessary / not a common pattern in backbone-forms?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philfreo I know... this is not a common pattern on this project, but also the List editor doesn't follow exactly the same pattern as the other editors.
Once you have inserted the form element into the DOM, a second call to listEditor.render() instead of updating the current element, will create a new one... this one new is not possible to trap or handle in any of the available events (there's no post-render trigger or something). So, this was the most viable solution I found =).

@rjmackay
Copy link
Contributor

Just had the same issue described here. Could this get merged?

@alemangui
Copy link
Contributor

+1

this.setElement($el);

//In case of there was a pre-existing element already placed in the DOM, then update it
if (domReferencedElement) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check the element has actually changed ? && old != new ?

@glenpike
Copy link
Collaborator

glenpike commented Sep 5, 2016

May have bearing on #517

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

Successfully merging this pull request may close these issues.

7 participants