Closed casql closed 10 years ago
It seems like you want to use a combination of setAnnotationData
and shouldLoadAnnotation
:
jQuery('#content').annotator().annotator("addPlugin", "Offline", {
setAnnotationData: function (ann) {
if (!ann.pageName) {
ann.pageName = jQuery('title').text(); // Use the page title
}
},
shouldLoadAnnotation: function (ann) {
return ann.pageName === jQuery('title').text();
}
});
Here, you'll need to replace jQuery('title').text()
with something unique to the page.
It works! Thank you very much, I was nowhere near to writing anything like this. Thank you!
Great, I'll add a block to the README to clarify this.
Hi everyone,
I am using annotator offline in a publication I am building with the Baker Framework. All of the pages (articles) are very similarly built, the only thing that changes is the actual text, not the markup.
The problem I am getting is that an annotation made in (say) the first
p
inside the#content
div of a singular article causes the same annotation to appear in every firstp
of the#content
div in every article.Is there a way around this? I have read the documentation and I suppose I would have to add an ID to every annotation made usinf
getUniqueKey
and/orsetAnnotationData
but I have no clue of how to write it. What I have so far is the plugin initiated with the sample code that you have in the example:Anything helps, thanks a lot!