Diff for "JavaScript"

Not logged in - Log In / Register

Differences between revisions 16 and 17
Revision 16 as of 2009-03-05 17:14:14
Size: 1578
Editor: mars
Comment:
Revision 17 as of 2009-03-11 10:37:08
Size: 1585
Comment: AFAICS the TAL string: modifier is required.
Deletions are marked like this. Additions are marked like this.
Line 20: Line 20:
<js tal:replace="structure <script>...</script>" /> <js tal:replace="structure string:<script>...</script>" />

JavaScript in Launchpad

This page covers everything to do with JavaScript development in Launchpad.

Some useful links:

Zope, JavaScript, and YUI3 Tips

Zope's TAL engine is clever, and helpfully breaks any <script> nodes in your template. Here's how to make the TAL interpreter do the right thing:

<js tal:replace="structure string:<script>...</script>" />


Zope3 forms have field names with dots in them, like this:

  <input id="field.action.visibility" name="field.action.visibility" type="hidden"/>

This makes it impossible to grab <input> nodes with CSS3 selectors, or with YUI3's Y.get() function.

For example, this will return null:

  Y.get('#field.action.visibility');

You can take advantage of Y.get()'s node-wrapping abilities to work around this. These all return a Node instance:

  Y.get(Y.DOM.byId('field.action.visibility'));
  Y.get(document.getElementById('field.action.visibility'));
  Y.get("#someform input[name='field.action.visibility']");


Sometimes you need to pass a raw DOM node into another JavaScript library, but YUI3's Y.get() function returns a YUI3 Node instance, which is incompatible.

You can unwrap the Node instance like this:

  var yui_node = Y.get('#foo');
  var raw_node = Y.Node.getDOMNode(yui_node);


CategoryCategory

JavaScript (last edited 2011-10-28 19:33:58 by flacoste)