O:prepare-value Event

Hello,

Question about the o:prepare-value trigger: when a value container is created in the form, I would like to grab the property that the value container is for. When o:prepare-value is triggered for a value that already exists, I can grab the property from the valueObj. However, when it’s an entirely new value container, there is no valueObj. So that’s not doable. The only way I’ve figured how to get the property is to parse it out of the aria-labelledby on the value container itself, ie aria-labelledby="property-6-label". Is there another way to do this that I’m missing? I’m not able to access the .resource-values parent, which also has the property info, because the value container passed from the trigger hasn’t been appended to the page yet.

Thanks,

Joseph Anderson

I think you’re probably right on the only accessible bit being the labelledby at that point… there’s “data-term” set to the value but it’s the term (“dcterms:title”, e.g.) rather than the ID.

makeNewValue itself just looks up the property ID using the term, so you could just do that as well: it gets the .resource-values.field that has a matching data-property-term and pulls the ID out of its property-id data entry.

That’s very helpful! I actually wasn’t aware of the ‘data-term’ because .data() doesn’t actually get written to the html so I didn’t see it. But it’s there to access using value.data('data-term'). The term alone works for my purposes :metal:

Best,

Joseph

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.