[annotator-dev] How to reload annotator when loading pages using Ajax

johnny jiang johnny.nan.jiang at gmail.com
Mon Jul 29 10:11:09 UTC 2013


Hi Rouan,

Thanks heaps for your kind and details advise, I will give it a go.

I noticed that you are from TW, and we do have a lot of ThoughtWorkers here
at Suncorp (my employer).

Thanks and regards,
Johnny


On Mon, Jul 29, 2013 at 8:03 PM, Rouan Wilsenach <rwilsen at thoughtworks.com>
 wrote:

> Hi Johnny
>
> You don't have to use the page's url as the uri for your annotations. The
> store plugin allows you to set 'annotationData' and 'loadFromSearch' which
> specify what uri the annotation will be saved with and searched by. You can
> set up the store plugin in a way similar to this:
>
> $(".somediv").annotator().annotator('setupPlugins', {}, {
>                       ...
>                          Store: {
>       annotationData: {
>         uri: someUniqueId
>       },
>       loadFromSearch: {
>         uri: someUniqueId
>       },
>           prefix: '/store'
>          },
> ...
>
> What may also help you is to extract your annotator setup into a method
> that you can call every time you add a new section to the page. So instead
> of $(".somediv").annotator(), you do something like this:
>
> var setupAnnotator = function(area){
> $(area).annotator()
> .annotator('setupPlugins', {}, {
>      ....
>         });
> };
>
> So that you can call setupAnnotator() and pass in the div you've just
> loaded to your page, which will set annotator up on it. You can also (from
> the server side) ensure that the unique id you want to use for the uri is
> embedded in what you pass through, like this:
>
> var setupAnnotator = function(area){
> $(area).annotator()
> .annotator('setupPlugins', {}, {
>      Store: {
>       annotationData: {
>         uri: area.id
>       },
>       loadFromSearch: {
>         uri: area.id
>       },
>           prefix: '/store'
>          },
>         });
> };
>
> Hope that helps.
>
>
> On 28 July 2013 04:54, johnny jiang <johnny.nan.jiang at gmail.com> wrote:
>
>> Hi folks,
>>
>> We are trying to apply annotator to an ebook reading website, where we
>> don't load each chapter as a new page, instead, we use ajax call to go to
>> next chapter without reloading the whole page.
>>
>> I was wondering how can I get annotator.js to reload all annotations for
>> the new page(url)?
>>
>> Can you please help?
>>
>> Thanks and regards,
>> Johnny
>>
>> _______________________________________________
>> annotator-dev mailing list
>> annotator-dev at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/annotator-dev
>> Unsubscribe: http://lists.okfn.org/mailman/options/annotator-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20130729/02972c88/attachment-0002.html>


More information about the annotator-dev mailing list