Pull data from the content of current element
| Project: | Metadata |
| Version: | 2.0 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
In general I think that people are going to make use metadata to grab data from a script element simply because it means that your HTML will continue to validate and you don't pollute your class with extra stuff (an issue if you have a lot of metadata). However, I can for see a situation where the element I'm currently working has two script tags with meta data, one to control the outer container (which is a funky show/hide block) and another to configure a calendar control for the date field.
While if you were hand coding things, it would be reasonable to put the metadata for both into a single block, its much harder if each of those constructs (show/hide and date fields) are generated using TagLibs (in a JSP) or a macro in a template. This is likely to happen in large scale applications where hand coding markup is error prone.
The simple solution is to add a new type called (for lack of a better word) "self" allowing you do do the following:
<div class="foo">
<script class="boo" type="application/json"> {foo: 'bar', test: 1}</script>
</div>
<script>
$(".foo .boo").metadata(type: "self").foo == 'bar'; //true
</script>