Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store plugin: how to send variable values in annotationData #714

Open
n8willis opened this issue Oct 28, 2020 · 6 comments
Open

Store plugin: how to send variable values in annotationData #714

n8willis opened this issue Oct 28, 2020 · 6 comments

Comments

@n8willis
Copy link

Let me start by saying this is very likely to be a jQuery issue, but for the life of me I'm turning up blanks on any answers that're real-world applicable. I've gone back through the entire mailing list archive (via the Wayback Machine...).

I have a deployment where I'm wanting to add some fields to the annotationData, but in which the values may change from annotation to annotation. And I'm not seeing how to set that up in a jQuery script for the annotator. What I need to capture is a straightforward bit of DOM info, but the setup for the Store plugin (apparently) gets evaluated on page load and doesn't see the updates. This is on 1.2, because touch support is a prerequisite.

Here's a minimal, but accurate, example. In thy page:

<script>
  jQuery(function ($) {
      var content = $('#content').annotator();
      content.annotator('addPlugin', 'Store', { prefix:
      'http://localhost:8888/store', annotationData: {'uri': window.location.href,
                                      'winwidth': window.innerWidth }
						    });
  });
</script> 

All I'm after here is to get the window.innerWidth, if it gets changed, but in my tests I get the initial value (correctly) on the first annotation, but changing the window size doesn't result in an updated value being sent with subsequent annotations. The storage backend is getting whatever is sent, so that's not the issue. It's the page.

Is there some easy answer I haven't found?

Like I said, I don't do jQuery stuff normally, and searching for examples just hasn't led anywhere at all; whether that's because search engines don't index stuff like $ in a way that leads to good results or there is something out-of-the-ordinary about the the sample code from the Annotator docs, I don't have any way to know.

@n8willis n8willis changed the title Store plugin: how so send variable values in annotationData Store plugin: how to send variable values in annotationData Oct 28, 2020
@zahqresh
Copy link

Have you tried adding an eventListener for this purpose and get a value of window.innerWidth save it to a var and then pass that value to the annotationData?

@n8willis
Copy link
Author

n8willis commented Dec 3, 2020

Well, like I said, I don't know jQuery, and although I've tried, I haven't succeeded.

You are saying that like it's not a convoluted process (which I believe; I just haven't been able to deduce some working code on my own). Would you mind showing an example snippet that does what you're suggesting?

@n8willis
Copy link
Author

Again, it would be helpful if you would include a snippet to illustrate what you're suggesting.

@n8willis
Copy link
Author

@zahqresh Really, can you elaborate even a bit on what you're suggesting?

@zahqresh
Copy link

Hi, sorry have been busy i'll look at the issue again and get back for more you cant send me an email and we can work on this if you want thank :)

@n8willis
Copy link
Author

@zahqresh Hi; any elaboration here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants