paul11
October 10, 2014, 12:46am
1
I just started experimenting with JS API. I was able to change "Metadata " and "Asset Status " of some assets (pages) successfully.
I was wondering if its possible to switch/change class applied to a div using JS API. I tried using setContentOfEditableFileAsset function.
I am not sure how to specify the "content":"content of file" parameter of this function ?
I am using this code :
function matrixSetContent() {
js_api.setContentOfEditableFileAsset({
"assetID":"38963",
"content":"content of file",
"dataCallback":function() {
alert("Class updated successfully")}
})
}
Here is the error I am getting, taken from console:
Uncaught Required argument "asset_id" missing
gscope.Squiz_Matrix_API._options
gscope.Squiz_Matrix_API.setContentOfEditableFileAsset
matrixSetContent
onclick
I am not even sure if setContentOfEditableFileAsset function is the correct function to use for this requirement (changing class)...!
Any help is highly appreciated.
Thanks
nnhubbard
(Nic Hubbard)
October 10, 2014, 2:57am
2
I think the manuals are wrong about what the argument name is for asset id. It should be asset_id, not assetID.
paul11
October 10, 2014, 3:58am
3
I think the manuals are wrong about what the argument name is for asset id. It should be asset_id, not assetID.
Thanks Nic, you were right. I changed the "assetID" to "asset_id" and now there is no error.
but what this code "content" : "content of file" , is doing ? Is it even correct ?
nnhubbard
(Nic Hubbard)
October 10, 2014, 4:45am
4
but what this code "content" : "content of file" , is doing ? Is it even correct ?
Have you tested it yet to see if the file contents get set? I cannot remember if you have to send it as a string or base64, but the manuals make it sound like a string.
paul11
October 13, 2014, 2:37am
5
Have you tested it yet to see if the file contents get set? I cannot remember if you have to send it as a string or base64, but the manuals make it sound like a string.
Hi Nic, no nothing seems to have changed in the file ...... Any other ideas or if you can point me to a working example, that would be great.
Thanks
nnhubbard
(Nic Hubbard)
October 13, 2014, 4:01pm
6
Hi Nic, no nothing seems to have changed in the file ...... Any other ideas or if you can point me to a working example, that would be great.
Thanks
What Matrix version are you on?