[Bug Report] dependent() when called with a object in fetch parameter, casts to string
[Bug Report] dependent() when called with a object in fetch parameter, casts to string

Tested in Editor 1.9.2
Per the dependent()
documentation, if you have an object in the fetch field:
As an object, this value is used as the options to make an Ajax request using jQuery's $.ajax() method. Please note that it is important you specify a url option otherwise the Ajax request will have nowhere to go! The format of the data submitted and the JSON data returned is discussed above.
However, the actual behavior experienced when passing the following object to dependent()
is a request to "[object Object]".
{
"url": "/Ajax/ClassOptions",
"headers": {
"__RequestVerificationToken": "..."
},
"data": {
"__RequestVerificationToken": "..."
}
}
Replies
The cause of the bug is this section of javascript:
As you can see, the ajaxOpts object is properly updated if the url is a plainObject. But when the call is actually made, the url is overwritten. Probably the easiest way to fix this would be commenting out the
url: url,
line. And that's what I've done temporarily. And for my use case it was also necessary to extend the data field.Thank you for the analysis! This will be fixed in 1.9.3.
Allan
I believe I am still seeing this in 1.9.6. Hmm it's kind of blocking me. Should I just use the fix suggested by @pcjackson ?
Apologies - it looks like I missed this one.
Yes, I concur that @pcjackson's fix is the correct one here. It can be applied locally until we deploy the fix.
Allan