The event: ZoteroItemUpdated appears to work only for Firefox

I'm finding that firing the event: ZoteroItemUpdated from our Web app doesn't trigger a call to the Zotero translator for browsers other than Firefox. This is an important function for AJAX based websites.

I tried using the Chrome and Safari connectors as well as using Zotero standalone without any success. I don't see any mention of this in the documentation or anywhere else.

It also appears that using the essentially undocumented function: Zotero.monitorDOMChanges() works in FF and Chrome but not Safari.
The additional problem with this function is that it requires a DOM change, so if only text and images are being changed, the event doesn't fire. We have 72 thumbnail images on a page when the user paginates to the next 72 images in the search results, the images and text are changed - but the DOM remains the same for performance reasons.

Any help would be appreciated.

John Justin
  • Can you provide a URL for testing?
  • The code is on our development server and the site is not available outside the firewall. But, it's fairly easy to test it with a few lines of JS.
  • Also, you're right that Zotero.monitorDOMChanges is not well documented, though this function only works when called from translators (it's not clear to me that you're actually working with a translator from your post above). When called from translators from detectWeb, it takes two arguments: the DOM node to monitor, and a MutationObserverInit object, which defaults to { childList: true, subtree: true }. Everything that applies to mutation observers, applies to monitorDOMchanges. Any time the mutation observer would be called, Zotero will cancel monitoring all nodes for changes and re-run detection on the page (so you have to restart monitoring for DOM changes)

    I'll take a look at the issue with ZoteroItemUpdated event some time today.
  • (Keeping this here instead of the dev list, since Aurimas has already responded.)
  • Thank you very much for the quick response. I just completed the development on our Zotero translator using FF; and was testing it on Chrome and Safari when I saw that the event: ZoteroItemUpdated was apparently not being handled in those two browsers.

    I guess if worst comes to worst I could do a hack and use Zotero.monitorDOMChanges in the translator - i.e., essentially create and destroy a DOM object on the page to get the translator triggered?
  • edited March 9, 2015
    Triggering ZoteroItemUpdated event as described in https://www.zotero.org/support/dev/exposing_metadata#force_zotero_to_refresh_metadata works for me in Chrome (someone else will have to test on Safari). By that, I mean that I see detectWeb being re-run (in the console log of the extension background page), though I can't say if the URL bar icon is getting properly updated, since I don't have a good website to test on (without hacking up some translator, which I don't have time for right now). For a website that relies heavily on Zotero.monitorDOMChanges, you might currently see a very significant performance impact due to https://github.com/zotero/zotero/pull/592 so if you can handle this via ZoteroItemUpdated event, that would be preferred (though merging that PR would be preferreder :-) )
  • aurimus, thanks. If you give me an email address, I can send you a username/pw to our app on a server that is outside the firewall.

    http://webcache.artstor.org/library. I can send you the translator code as well.
  • For the translator, you're welcome to start a pull request on github (unless you don't want to make it public yet). My email is listed here: https://github.com/aurimasv
  • Thank you aurimas. Will this fix appear in a 4.0.26.2 release soon?
  • It hasn't been accepted, so I'm not sure when it will be released.
  • OK. Thanks again.

This is an old discussion that has not been active in a long time. Before commenting here, you should strongly consider starting a new discussion instead. If you think the content of this discussion is still relevant, you can link to it from your new discussion.

Sign In or Register to comment.