Displaying entries containing a particular morpheme (#2)
This feature is now complete, and appears to be working well (tested in Firefox, Opera, Chrome, IE8 and IE9). In making it work, I had to overcome problems relating to recursion. When a call is made to retrieve an entry for embedding inside another entry, my code naturally checks to see if we already have a copy of that entry on the page; if we do, it just makes a copy of it and uses it, rather than pulling it down again from the server via AJAX. However, that naturally means that any id attributes in the original tree need to be changed so that we don't have multiple elements on the page with the same id. I was already doing that with the id of th root node, but I had to make several more similar changes for nested entry lists:
- The nested entry naturally has its own "Other entries" link and container; the container had to be emptied of retrieved
<div>s. - The id of the container had to be changed to a unique id.
- The onclick event of the link had to be changed to point to the new id of the container.
This is a little messy, and in fact the same code appears in two places in the JavaScript, so my next job is to modularize it. It amounts to sanitizing a copied node tree.