> <script>
...
> createTiddlyElement(place,"span",null,null, cnt);
> </script>

Note: you don't need to use createTiddlyElement(...) to produce output
from embedded inline javascript.  Simply return a TEXT value, and it
will be automatically 'wikified' and rendered where the script is
embedded.  In your suggested script, since 'cnt' is a numeric value,
you would write:
   return cnt.toString();

Also, the technique of looking for all checkboxes contained with
{{count{...}}} is not sufficient: suppose you have rendered several
different tiddlers, each with checkboxes wrapped in {{count{}}}.  In
that case, jQuery would find the checkboxes in all the rendered
tiddlers, not just the current one.

Fortunately, since you are using InlineJavascriptPlugin, there is an
alternative: The 'place' variable, which is automatically defined by
the plugin for use within scripts, can be used to make *relative*
references to the last element rendered into the current tiddler
(i.e., 'place.lastChild'), like this:

{{count{...}}}<script>
var a=jQuery(place.lastChild).find('.chkOptionInput')
var c=0;
for (var i=0; i<a.length; i++) c+=a[i].checked?1:0;
return c.toString();
</script>

Note: for place.lastChild to refer to the {{count{...}}} element, it
must be rendered *immediately* before the inline script (with NO
intervening content... not even whitespace).

You can also place the above script into a tiddler (e.g.,
[[CountCheckmarks]]) and then transclude it, like this:
   {{count{...}}}<<tiddler CountCheckmarks>>

Important note: when using transclusion, the script is automatically
wrapped inside a containing DIV.  As a consequence, the relative
reference to
   place.lastChild
in the first line of the script needs to be changed to
   place.parentNode.lastChild
like this:
   var a=jQuery(place.parentNode.lastChild).find('.chkOptionInput')

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to