I wonder if I could have a scenario like this:

I paste a list of students into a tiddler and call it
"ListToTags" (Maybe overwriting earlier version-(doesn't matter)).
When I hit my scriptbutton to make a new class - it prompts for a
classtitle and teachers initials - now it takes the text from
"ListToTags" and puts it into the newClasstiddlers tagfield - done...
ProtoType: (doesn't work yet..)

<script label="L2T" title="List2Tags">
  var tid=prompt("ClassTitle","");
        if (!tid || !tid.length) return;
        var txt="";
        var who=config.options.txtUserName;
        var when=new Date();
        var tags=['Fag'];
        var initialer=prompt("Teachers initials","");
        if (!initials || !initials.length) return;
        var fields={ teacher: initials };
        store.saveTiddler(tid,tid,txt,who,when,tags,fields);
        story.displayTiddler(null,tid);
   var t=store.getTiddlerText(tiddler.title) ;
   var target = store.getTiddler(tiddler.title) ;
   var taglist = t.split('\n') ;
   for(var i=0 ; i < taglist.length ; i++) {
    if ( taglist[i] && ! target.tags.contains(taglist[i]) )
target.tags.push( taglist[i] ) ;
   }
  return 'List 2 tags - click edit and done' ;
</script>

Could this become reality??

YS Måns Mårtensson

On 12 Apr., 21:06, Måns <[email protected]> wrote:
> I tried this:
> <script label="L2T" title="List2Tags">
>    var here=store.findContainingTiddler(place);
>    if (!here) return;
>    var title=here.getAttribute("tiddler");
>    var tiddler=store.getTiddler(title);
>    var t=store.getTiddlerText(tiddler.title) ;
>    var target = store.getTiddler(tiddler.title) ;
>    var taglist = t.split('\n') ;
>    for(var i=0 ; i < taglist.length ; i++) {
>     if ( taglist[i] && ! target.tags.contains(taglist[i]) )
> target.tags.push( taglist[i] ) ;
>    }
>   return 'Liste er overført til tags - klik redigér og færdig i
> tiddleren' ;
> </script>
> And got this: TypeError: store.findContainingTiddler is not a function
> when I tried to invoke it...
>
> What am I doing wrong?
>
> YS Måns Mårtensson
>
> On 12 Apr., 19:29, Måns <[email protected]> wrote:
>
> > TypeError: store.findContainingTiddler is not a function....
>
> > On 12 Apr., 18:26, Eric Shulman <[email protected]> wrote:
>
> > > > I'd like the script to be active in the tiddler it is invoked from.
> > > > I thought that tiddler.title would do that for me - when I used the
> > > > script from another tiddler with <<tiddler MyScript>>
> > > > However it runs the script in the original tiddler instead (putting
> > > > the script itself into the tagline!!)..
>
> > > The 'tiddler' object that is provided by the core always refers to the
> > > tiddler in which the wiki source is *stored* (the 'source tiddler'),
> > > and is usually the same as the tiddler being *rendered* (the
> > > 'containing tiddler').  However, when you use <<tiddler>> to
> > > transclude content from a separate TiddlerName, the source tiddler is
> > > different from the containing tiddler.  In this case, in order to
> > > ensure that you get the correct tiddler title and/or tiddler object,
> > > you'll need to use the 'findContainingTiddler()' technique I
> > > previously described:
>
> > >    var here=store.findContainingTiddler(place);
> > >    if (!here) return;
> > >    var title=here.getAttribute("tiddler");
> > >    var tiddler=store.getTiddler(title);
>
> > > -e
--~--~---------~--~----~------------~-------~--~----~
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