When working with KnockoutJS, the with
binding allows you to change the current binding context. So if you have a nested data structure, instead of having to binding to properties such as subViewModel.property1
and subViewModel.property2
, you can put them inside a with
binding and then refer to them directly as property1
and property2
, respectively.
This is quite useful in keeping your views from getting too cluttered when your viewmodel structure gets large. However, if you jump down more than one level in a single the with
binding, it’s not immediately apparent what the $parent
context will refer to.