[annotator-dev] Custom Storage Plugin
Jamie McGowan
jamietyc at gmail.com
Fri Jul 31 14:04:28 UTC 2015
Hi,
I am writing my own storage backend in PHP and also a JavaScript plugin to
send/retrieve the data to the server. I don't want to use the default store
plugin.
I have subscribed to the "beforeAnnotationCreated" event. When it is fired,
I attach the url to the annotation. I have also subscribed to the
"annotationCreated" event. When it is fired, I attempt to send to
annotation to the server via Ajax. However I get the following error:
*Uncaught Error: Error while finding start node: undefined: TypeError:
Cannot read property 'substring' of undefined.*
It seems to me that the annotation object is no longer available. I have
attached the code below (hopefully the format doesn't get messed up).
I appreciate any help!
Jamie
Annotator.Plugin.Storage= function(element) {
return {
pluginInit: function() {
this.annotator
.subscribe("beforeAnnotationCreated",
function(annotation) {
annotation.url = document.location.href;
})
.subscribe("annotationCreated", function(annotation) {
console.log("Created: %o", annotation); //This works as
expected
jQuery.post("./annotator/create.php", annotation,
function(data) {
annotation.id = data.id;
annotation.username = data.username;
annotation.timecreated = data.timecreated;
}); //This doesn't work
})
}
}
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20150731/659c09b1/attachment-0003.html>
More information about the annotator-dev
mailing list