Javascript Zombies

Javascript examples tend to zombify quite fastly. It’s pretty easy to make up a page for showing something, but very soon that page becomes unusable. I’m constantly finding many broken javascript examples in the internet.

And the semantic of a broken javascript example is a logic problem nobody can solve. Is it broken by accident or on purpose? Was it already broken when created? Who, what, where, when did it break? Is it a browser test? Am I doing something wrong?

Maybe we should refrain from presenting online examples.

SPAM is not that bad

Every day SPAM comments remind me that my blog comment feature is properly working even if almost none of my readers is taking time to reply to my posts.

Metaobjects 1.1 Released Today

The Metaobjects plugin is going to become a jQuery official plugin, starting from the next jQuery 1.1 release, due out in a week or so. Meanwhile I’ve come up with some improvements that I’m going to share with you, releasing a new version of Metaobjects.

Changes

  • Added a new option for selecting the metaobjects to process. The option name is “selector” and its value is a jQuery selector, which defaults to “object.metaobject”, i.e. an OBJECT element with a ‘metaobject’ class (the metaobject definition).

Example: process metaobjects selected by “object.bar”

  • Added the concept of metaparam for configuring options local to a metaobject. If a PARAM element is given the ‘metaparam’ id, then it is treated as a configuration element, not a metadata element. Either one or none of the PARAM elements can be a metaparam. Its name is needed but not used. A good choice could be ‘options’ or ‘configuration’, anyway the ‘metaparam’ id garantees that it won’t clash with a metadata name you might need.
  • Fixed a bug that didn’t allow metaobjects to add metadata to elements without a closing tag, like images (thanks to John Resig for pointing it out). Now this is possible by means of the ‘target’ metaparam option, whose value is a jQuery selector, which defaults to the parent of the metaobject. The selector takes the document as its context.

Example: add this metadata to all the elements selected by “img.foo”

Code of Metaobjects 1.1

Tests

These tests show what happens when the metaobjects() function is called with different options on the same page. (only the name of the file changes)

  • test.hml
  • test1.hml
  • test2.hml
  • test3.hml

XHTML page

setup.js