However, the introduction of AJAX (WikiPedia:AJAX) has made this strict separation much harder to accomplish. How can a complex, asynchronous web-page be separated into widgets and controllers? Yet without this separation, both widget reuse and automated controller plumbing becomes impossible.
[Meatball's caching statistics] demonstrates a simple widget: the two statistics are kept up-to-date asynchronously. The entire HTML to achieve this is:
<span class="synchronized" id="cache-percentage">99.1% (4331)</span>
This "synchronized" widget connects to the [cache-percentage] URL once a minute, and refreshes the information.
The DojoToolkit? uses the class attribute to transform normal HTML elements into widgets as well. However, it currently requires non-standard attributes to pass parameters into the widgets, breaking HTML compliance. (The current version can use namespaces on these attributes, which is claimed to restore compliance, but the W3C Validator disagrees .) The solution above has the nice property of being fully-compliant with the HTML and XHTML standards, as id attributes are allowed on any element.