knockout.js - Resetting dropdown by manual subscription doesn't work depending on what observable was subscribed to -


I searched online and tried to understand this behavior and work hard but I just could not find out that this behavior Why is it possible that I am missing something fundamental here?

I would appreciate some hints / resources / answers.

Consider this Bela -

Why it Resets Product Selection

  // Whenever the category changes, the product selection Reset self.category.subscribe (function () {self.productName (undefined);});  

While this is not it?

  // Whenever the category changes, reset product selections self.categoryName.subscribe (function () {self.productName (undefined);});  

It must be done from the order in which the subscribe event The other is called relative to the computed properties computed and subscribe properties of D are said in the same order when they were viewed There is a change on the property. Here's what is happening in each case, this is the best thing, as I can tell (Kendo has not read the source, so there is some guess):

category.subscribe:

  • Code> Category
  • Code due to change in category Updated property is updated category

    Note: productName is still the old value at this point

  • category. ProductName
  • Change the calculation value of product the event is converted the property calculated due to the change in Product Name

    Note: productName is undefined now

  • all dependent Computed properties and membership events have been completed on c productName and the product list undefined >
  • catego RyName.subscribe:

    1. The category dropdown is manipulated by the user, the new value is set
    2. categoryName
      < category name view is updated due to change in / code>
    3. category category

      Note: Due to the change in productName

    4. the product still has the old value at this point

    5. Complete all dependent-computed properties and membership events category Has been updated, so updated on the basis of kendoDropDownList new products list and the current ( of productName

      No undefined ) value

      I tested the candodeupdownlist Ode> and it chooses the first option even if you have productName Dummy string such as 'asdf' is set to. It shows only empty if the value is empty string ( '' ) or undefined .

      Event is to be converted to the value of productName
    6. Note: productName is Undefined now

    7. class does not update it again because it Products are not dependent on or productName , but should update Candodeupdualist

      < / P>

      Down is created first (in this example, it is in step 5). If you add logic to optionLabel in kendoDropDownList , then it will work as expected, even then.


    If you enter categoryName.subscribe before, category = ko.computed (...) First, then the whole cycle begins before productName to undefined which will be a way to fix it. Here is a Bella:

    Another way is to describe the optionLabel parameter as KandodaproductionList option hash as described in step 8. >


    Comments

    Popular posts from this blog

    import - Python ImportError: No module named wmi -

    Editing Python Class in Shell and SQLAlchemy -

    c# - MySQL Parameterized Select Query joining tables issue -