Hi Eric Some day - when I have the the time/loose my job as a teacher - I will collect your answers into a TW titled MagicalShulmanQuotes4all2enjoy... Thank you very much!!
YS Måns Mårtensson On 9 Apr., 23:14, Eric Shulman <[email protected]> wrote: > > I' like to make a macrobutton which will ask for a value for a > > predefined fieldname. > > My button looks like this(without any specified fieldname yet): > > <<newTiddler title: 'Name of class' tag: 'Class' label: 'New class |' > > text: {{store.getTiddlerText("ClassSliderFrame")}}>> > > > Could I predefine a fieldname: teacher - and prompt for a value?? > > The user pushes the button and is asked to write the teachers initials > > (fieldvalue) - > > The <<newTiddler>> parameter syntax for setting a field value is: > field:"name:'value'" > (note use of both single and double quotes) > Thus: > field:"teacher:'MM'" > To prompt for a value instead of using a fixed constant (e.g, "MM"), > you could use a computed parameter to automatically invoke a prompt() > dialog box to ask for the teachers initials, like this: > field:{{"teacher:'"+prompt("Enter teacher's initials","")+"'"}} > > However... there's one catch: the <<newTiddler>> macro's computed > parameter will be evaluated (and the dialog box will be presented) > when the the "new class" command link is initially *rendered*, while > what you need is for the dialog box to be invoked each time you > *click* on the command link. > > Fortunately, I have a solution: > http://www.TiddlyTools.com/#ClickifyPlugin > After installing, just write: > <<clickify newTiddler ... field:{{...}}>> > The additional 'clickify' keyword at the beginning of the macro will > cause any computed parameters to be invoked 'on click' instead of 'on > render', giving exactly the sequence you are after (i.e., click > command, display dialog, input initials, press OK, create tiddler) > > > 2) > > The tiddler is created - and there isn't really any reason why it > > should open in editmode - because it's already filled with a template > > provided by the ClassViewTemplate... Can it just proceed to viewmode - > > at once?? > > Actually, this is even simpler than the above... by using > InlineJavscriptPlugin, you can write a custom 'onclick' command that > performs *any* scripted action you want, including creating new > tiddlers from prompted values and showing them... like this: > > <script label="new class" title="create a new class"> > var tid=prompt("Enter name of class",""); > if (!tid || !tid.length) return; > var txt=store.getTiddlerText("ClassSliderFrame"); > var who=config.options.txtUserName; > var when=new Date(); > var tags=['Class']; > var initials=prompt("Enter teacher's initials",""); > if (!initials || !initials.length) return; > var fields={ teacher: initials }; > store.saveTiddler(tid,tid,txt,who,when,tags,fields); > story.displayTiddler(null,tid); > </script> > > 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 -~----------~----~----~----~------~----~------~--~---

