backbone.stickit icon indicating copy to clipboard operation
backbone.stickit copied to clipboard

state of select's options is being reseted on simple model update

Open sergey-dev opened this issue 10 years ago • 2 comments

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.

sergey-dev avatar Sep 26 '14 16:09 sergey-dev

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.

sergey-dev avatar Sep 29 '14 17:09 sergey-dev

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 attributes - style, etc. If viable, please accept @sergey-dev PL ! A working example of the issue:

https://jsfiddle.net/cancerbero_sgx/xztuzg0d/

cancerberoSgx avatar Sep 18 '17 21:09 cancerberoSgx