knockout / knockout

Knockout makes it easier to create rich, responsive UIs with JavaScript
http://knockoutjs.com/
Other
10.45k stars 1.52k forks source link

There is a "problem" with selected options subscriptions #377

Closed SharpNoiZy closed 12 years ago

SharpNoiZy commented 12 years ago

Hi,

there is a problem I run into, and a solution for that would be great.

Until now it is not possible to react (subscripe) to a selected options viewmodel variable, because it is one time fired twice! This is because change the selectbox variable will also fire the selected variable subscription what is a problem if you do something complex on the change of the selected variable.

It is hard to descripe, so look at the jsFiddle to see what I mean: http://jsfiddle.net/NoiZy/ytxBg/

Best regards

SharpNoiZy commented 12 years ago

Please, can someone answer on that, mbest?

I'm working very much with selectboxes, and for me it is a no go (I think the last) for KO, and I want to use KO that much!

Best regards

mbest commented 12 years ago

The basic cause of this problem is that bindings for a single element are always updated together. There are a few solutions you can try.

  1. Use my Knockout fork that adds the ability to process bindings independently: updated fiddle; Documentation.
  2. Use my async binding that allows you make a specific binding independent: updated fiddle; Documentation.
  3. Wait for my independent bindings update to be merged into Knockout (another few months or so).
SharpNoiZy commented 12 years ago

OK, great!

Thank you very much! I hope Steve will merge this quick into the "real" knockout.

SharpNoiZy commented 12 years ago

There is a another bug in Knockout, post it in the Forum. https://groups.google.com/forum/?fromgroups#!topic/knockoutjs/aVsa56XmXHs

Updated my jsFiddle: http://jsfiddle.net/NoiZy/ytxBg/

Best regards

sagacity commented 12 years ago

@mbest, Will all of your fork's changes be incorporated or only the changes related to bindings re-evaluating only themselves? We are running into issues as well, when we have a lot of options in a SELECT. It gets rerendered a lot! :)

mbest commented 12 years ago

@RoyJacobs I'm not sure what will be included when.

mbest commented 12 years ago

Same as #321; closing.