English 中文(简体)
jsFiddle——有选择的逻辑
原标题:jsFiddle - logic with select

I have started a jsFiddle to see if someone can kindly help me to fix a logic problem I have in my attempt to use cascanding selects with added captions. It is partially working

I have two selects and would like to add captions to advise the user what to do and expect. I have tried using ko.computed as Flo sugggested but my logic is still not right.

THIS IS THE LOGIC

select1 = Poster Select select2 = Client Select

一个邮局可以有许多客户。

1 - If the view model s POSTER ARRAY LIST is empty I add No Posters caption to select1. I also 增加上限2 不包括客户and disable both selects

2 - If the view model s POSTER ARRAY LIST has only one item I display the current item and no caption

         if the selected Poster object has no ClientSite array, I 

增加上限2 不包括客户

         if the selected Poster object has only one item in the 

ClientSite array, I display the current ClientSite item in select2 and disable the select2

         if the selected Poster object has a collection of 

客户,我在选择2时展示选择性客户上限

3 - If the view model s POSTER LIST has many items, I display a caption in in select1 Select Poster

         if the selected Poster object has no ClientSite array, I 

to 增加上限2 不包括客户

         if the selected Poster object has only one item in the 

客户阵列,我展示该项目,可以选择2

         if the selected Poster object has more than one item in 

the ClientSite array, I display Select Client in select2

When I select an item in select1 that has items in the ClientSite and then go back to the caption Select Poster , I get an error. I think the reason for this is that I am changing from an object to a string but select2 is expecting an object.

Please could someone share some light?

卡车

C

问题回答




相关问题
How to go from DOM node to viewModel object?

When the drop function is called back, this is set to the droppable DOM node (the target) and ui.draggable is the DOM node which was dragged. Is there an idiomatic way of getting the model object ...

making fields observable after ajax retrieval in knockout.js

I am wondering how I can make certain fields observables in knockout.js that I get from an ajax call without having to define the whole object in my viewmodel. Is this possible? Here is what I have ...

ASP.NET MVC Validation with jQuery $.ajax

I have a situation where I am sending data to a Controller via jQuery $.ajax, the data is a serialized json string. (MVC 3.0) It binds it fine - my controller receives the results and they are ...

Knockout.js and MVC

Just started playing with knockout.Js which is a fantastic framework Steve s really done well with that one. One thing I can t seem to do at the minute is impliment it with my Html Helpers. So for ...

Anyone using Knockoutjs with asp.net-mvc in anger? [closed]

I find it very interesting and have a prototype working based on Steve s mvc sample and another small sample from this thread. Using json.net to deserialize within the post action as I couldn t ...

热门标签