-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Given: A custom mapping option to map and unmap a model.
Running this code
var model = ko.viewmodel.toModel(vm);
$.ajax({
type: "POST",
url: "/someService",
dataType: "json",
data: model
})
produces an exception because jquery (2.1.1) runs into this
// Convert data if not already a string
if ( s.data && s.processData && typeof s.data !== "string" ) {
s.data = jQuery.param( s.data, s.traditional );
}
and in the end executes the custom mapping function without passing an object to the map-function.
The reason for this is that the model still has 2 functions defined:
___$mapCustom and
___$unmapCustom
Workaround
var model = ko.viewmodel.toModel(vm);
delete model._$mapCustom; // cleanup model
delete model._$unmapCustom; // cleanup model
$.ajax({
type: "POST",
url: "/someService",
dataType: "json",
data: model
})
Metadata
Metadata
Assignees
Labels
No labels