Help creating my first block

Permalink
I am building my first block which creates something like the following:
<span class="node_elem" data-id="58"> </span>

JavaScript will make a XMLHttpRequest which includes the data-id and C5 will use cURL to forward the request to another server, return the response to the browser client, and JavaScript will update the DOM as applicable.

To add the block, the user enters a few letters in the form and similarly an XMLHttpRequest is generated which again gets proxied to the other server and a list of possible matches are returned.

Don't think it is relevant, but the block will be available with a shared single page package.

Two questions:

1. Can the data-id value (i.e. 58) solely be stored in the HTML or must it actually be stored in the C5 DB which uses it to create the HTML tag?
2. Whether there is one or many of these blocks on a given page, the page must include the following only once. Is this automatically handled by C5's asset functionality?

<script src="updateNodeElements.js"></script>
<script>
   UpdateNodeElements(document.querySelectorAll("span.node_elem"));
</script>

Thanks

 
hutman replied on at Permalink Reply
hutman
1) If this ID needs to be created/selected by the user it must be stored in the database.

2) Yes, if you create 2 assets for this (or 1 asset and a view.js in the block) it will only be included on the page once.