-1

I want to transfer observable array along with model to controller. I did my surfing and found custom model binding is good for my situation.
But again its given I can use controllerContext.HttpContext.Form.Get("Day"); where as Day is Day

I have used select and element of select is stored as observable array.... if I can't use array, I can use select name or id as above situation... how do I do it... because select has many options...

and I'm new to custom model binding so I'm confused which code I've to put where...where do I put custom binding code with IModelBinder interface

Johan
  • 74,508
  • 24
  • 191
  • 319

1 Answers1

0

i think this will help you

function MyViewModel() {
var self = this;
self.value1 = ko.observable();
self.value2 = ko.observable();
ko.computed(function() {
    $.ajax({
        url: '/path/to/server/endpoint',
        type: 'POST',
        data: {
            value1: self.value1(),
            value2: self.value2()
        }
    });
});
}
Gaurang s
  • 831
  • 6
  • 18
  • thank you vivek... but what if i have a view model along with it.. do i get two argument in action, one for model and one for obserable array – Nandlalaji Singh May 03 '14 at 11:06
  • can u share your code? or fiddle ? so i can give u perfect solution – Gaurang s May 03 '14 at 11:09
  • ya you can take two arguments – Gaurang s May 03 '14 at 11:24
  • http://jsfiddle.net/LmLbU/ the above one is part of code...My full code is too lengthy... Though i have used holiday as one of viewmodel element, which is not list. i m getting observable array..now i want to pass that array to my action along with other viewmodel element – Nandlalaji Singh May 03 '14 at 12:22