Cascading dropdown

57 views
Skip to first unread message

Mohammed Rayees Afroz

unread,
Jan 7, 2016, 5:22:06 AM1/7/16
to Knockout MVC

Trying to implement cascading dropdowns.
But it goes in infinite ajax call loop when the first dropdown value is changed.
Any ideas?

Алексей

unread,
Feb 22, 2017, 12:31:38 PM2/22/17
to Knockout MVC
I have the same problem!

I've found the only solution - handling onclick event instead of onchange but I still have 1 extra server call when user clicks on the first dropdown to select needed item.

Алексей

unread,
Feb 24, 2017, 4:24:26 PM2/24/17
to Knockout MVC
I've found the solution: you have to attach the handler AFTER applying the model.

The code should look like following:

@ko.Apply(Model)

<script>
    $("#yourFirstList").change(function () { updateSecondList(); });
</script>

For me it works OK, no extra calls, no loops etc.
Reply all
Reply to author
Forward
0 new messages