backbone.stickit
backbone.stickit copied to clipboard
state of select's options is being reseted on simple model update
I think i found the issue within stickit plugin, which leads to unexpected behavior with the DOM.
Preconditions:
I've gotten dropdown with some options hidden, that's disabled = true
. After change of model, the state of dropdown changes, and after the update, the state of my options with disabled state is being reseted.
Take a look to the line #581:
$el.find('*').remove();
I'm just wondering, why you are doing wipe of all options from the select and then recreating them, if the only thing we need is to select another option on backbone.model.set() event.
I think, normally, you shouldn't affect the state of css, binded events to DOM, or the overal state of attributes except the attribute you need to update.
Here's the provided fix from my side.
it will not wipe the state of attributes like CSS, disabled states, HTML5 data attributes..
Each time we kill all the dropdowns content in line #581: $el.find('*').remove();
each option's CSS, and other attributes will be preserved, and restored.
Two way bindings works as it worked before, this way we just do not wiping the state of options' attributes on simple sync from backbone.model.set() -> view.
I'm also having this issue and I consider it a big issue: as a user I dont expect that the binding library to resent all my
https://jsfiddle.net/cancerbero_sgx/xztuzg0d/