[twdev] simple form example

11 views
Skip to first unread message

Mike

unread,
Apr 17, 2010, 1:18:19 PM4/17/10
to TiddlyWikiDev
does anyone have a simple input box, ok button - that adds text to the
containing tiddler?

just looking for an example I can deconstruct - macro, script, ect.

Thanks,
Mike

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To post to this group, send email to tiddly...@googlegroups.com.
To unsubscribe from this group, send email to tiddlywikide...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tiddlywikidev?hl=en.

Eric Shulman

unread,
Apr 17, 2010, 1:48:50 PM4/17/10
to TiddlyWikiDev
> does anyone have a simple input box, ok button - that adds text to the
> containing tiddler?
> just looking for an example I can deconstruct - macro, script, ect.

Try this:
http://www.TiddlyTools.com/#QuickNote

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

Mike

unread,
Apr 17, 2010, 2:03:35 PM4/17/10
to TiddlyWikiDev
thank you ELS,
very similar to http://www.tiddlytools.com/#FAQ_CreateTiddlersFromForms

How would I change the output to the containing tiddler vs a new
tiddler?

Mike

Mike

unread,
Apr 17, 2010, 2:26:12 PM4/17/10
to TiddlyWikiDev
Maybe I am looking for something like:
http://www.tiddlytools.com/#CommentPlugin

Not exactly a simple example though :P

Mike

On Apr 17, 1:03 pm, Mike <eris...@gmail.com> wrote:
> thank you ELS,
> very similar tohttp://www.tiddlytools.com/#FAQ_CreateTiddlersFromForms

Eric Shulman

unread,
Apr 18, 2010, 5:55:52 AM4/18/10
to TiddlyWikiDev
> How would I change the output to the containing tiddler vs a new
> tiddler?

To get the title of the containing tiddler (using HTML <a> element):
var t=story.findContainingTiddler(this).getAttribute('tiddler');

To get the title of the containing tiddler (using eval params or
inline script):
var t=story.findContainingTiddler(place).getAttribute('tiddler');

Then, use it the same as before:
var tid=store.getTiddler(t);
...etc...

enjoy,
-e

Mike

unread,
Apr 18, 2010, 1:36:14 PM4/18/10
to TiddlyWikiDev
Thank you for the feedback / example,
I think I have a good starting point now.

Mike
Message has been deleted
Message has been deleted
Message has been deleted

Mike

unread,
Apr 22, 2010, 5:23:12 PM4/22/10
to TiddlyWikiDev
So good so far !

<html><hide linebreaks><!-- see HTMLFormattingPlugin --><form
action="javascript:;"
onsubmit="
/* validate new title */
var t=story.findContainingTiddler(this).getAttribute('tiddler');

/* get current tiddler (if any) */
var tid=store.getTiddler(t);
var who=tid?tid.modifier:config.options.txtUserName;
var when=tid?tid.modified:new Date();0
var txt=tid?tid.text:'';
var tags=tid?tid.tags:[];
var fields=tid?tid.fields:{};

/* get form values and construct new tiddler text */
var fmt='\n*%0';
var newtxt=fmt.format([this.field1.value]);

/* insert new text at marker (or end, if no marker) */
var marker='/%MARKER%/';
if (txt.indexOf(marker)==-1) txt=txt+newtxt;
else txt=txt.replace(new RegExp(marker.escapeRegExp()),newtxt
+marker);

/* write and show tiddler */
store.saveTiddler(t,t,txt, who, when, tags, fields);
story.displayTiddler(story.findContainingTiddler(this),t);
return false;">
<input name="field1" value="QuickTask Here" onfocus="this.select()"
style="width:50%">
<input type="submit" value="+">
</form></html>

Reference:
http://www.tiddlytools.com/#FAQ_CreateTiddlersFromForms

Mike

On Apr 21, 5:03 pm, Mike <eris...@gmail.com> wrote:
> My Example form:
>
> <html><nowiki><form class="quickNote" style="display:inline;margin:
> 0;padding:0;white-space:nowrap;">
> <input type=text name="txt" style="width:50%">
> <input type=button value="save" style="width:8%" onclick="
>         var who=config.options.txtUserName;
>         var when=new Date();
>         var tags=story.findContainingTiddler(this).getAttribute('tags');
>         var title=story.findContainingTiddler(this).getAttribute('tiddler');
>         var text=tiddler.text+this.form.txt.value;
>         store.saveTiddler(title,title,text,who,when,tags,{});
>         story.displayTiddler(null,title);
> "></form></html>
>
> Reference:http://www.TiddlyTools.com/#QuickNote
>
> Mike
>
> On Apr 21, 2:23 pm, Mike <eris...@gmail.com> wrote:
>
>
>
> > Quick question concerning the output of the form
> > In QuickNote the following line is used
> > var text=this.form.txt.value;
> > Which if used when adding to the containing tiddler replaces the
> > content of that tiddler
> > So I used
> > var text=tiddler.text+this.form.txt.value;
> > Which adds the text from the form directly after the macro
> > I.E. <<tiddler transclusion>>text from form
>
> > I would like to add this text to a new line as a list
> > I.E.
> > <<tiddler transclusion>>
> > *text from form
>
> > I tried a few variants of
> > var text=tiddler.text+"/n*"+this.form.txt.value;
> > and I tried breaking it up into different variables and stitching it
> > back together. . .
>
> > I am sure I am missing something simple (syntax?)
>
> > Thank You !
>
> > Mike

Mike

unread,
Apr 23, 2010, 8:52:27 AM4/23/10
to TiddlyWikiDev
A question concerning the output. . .
I would like to add the class of .custom or {{custom{ output }}}
Can I add this via JS / JQ ?

document.getElementById('nav').className='isDOM';
or
jQuery('p').addClass('myClass yourClass');

My Stlye
.custom ul {
list-style: none;
}
.custom ul li:before {
content: "↕ \0020";
}

Could I use li / ul as the ID?

Mike

Mike

unread,
Apr 24, 2010, 3:09:04 PM4/24/10
to TiddlyWikiDev
http://groups.google.com/group/tiddlywiki/browse_thread/thread/38854e591c386b36

<script>jQuery("div.viewer").addClass("custom");</script>

Works as desired (as far as I can tell . . .)

Mike
Reply all
Reply to author
Forward
0 new messages