Here's my go at it:
http://dl.dropbox.com/u/3105342/TW/karakaterer/karakterMM.html#testCountCheckmarks%20CountCheckmarks
Maybe you can tell me what to change - to make it work...

Regards Måns Mårtensson

On 22 Mar., 16:18, Måns <[email protected]> wrote:
> Hi Mario and Eric
>
> Can I use the transclusion like this??:
> 1) I create a tiddler [[CountCheckmarks]]
> {{count{...}}}<script>
> var a=jQuery(place.parentNode.lastChild).find('.chkOptionInput')
> var c=0;
> for (var i=0; i<a.length; i++) c+=a[i].checked?1:0;
> return c.toString();
> </script>
> 2)
> I another tiddler I use a checkbox toggle like this:
> {{CountCheckmarks{
> |<<tiddler Check##toggletag with: 1>>|
> |<<tiddler Check##toggletag with: 2>>|
>
> }}}<<tiddler CountCheckmarks>>
>
> Ps:
> 2b) [[Check##toggletag]] is:
> !toggletag
> <html><hide linebreaks><form style="display:inline">
>         <input type="checkbox" name='c' onclick="
>                 var 
> tid=story.findContainingTiddler(this).getAttribute('tiddler');
>                 store.setTiddlerTag(tid,this.checked,'$1');
>         ">
> </form></html><script>
>         var
> t=store.getTiddler(story.findContainingTiddler(place).getAttribute('tiddler 
> '));
>         place.lastChild.getElementsByTagName('form')
> [0].c.checked=t.isTagged('$1');
> </script>
> !end toggletag
>
> I've tried this - but it doesn't seem to work for me.. - it returns
> "...0 "
>
> Regards Måns Mårtensson
>
> On 22 Mar., 12:22, Eric Shulman <[email protected]> wrote:
>
>
>
> > > <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