Thank you, now it works, with the change you suggested. Strange thing the closeAll did work in the old code but not he saveChanges. Any way, thanks :)
On Apr 5, 3:33 pm, magev958 <[email protected]> wrote: > Hi, I have managed to create a simple form with a autosave onClick- > function and it seems to work, but it seems it saves the TiddlyWiki > and THEN creates the new tiddler. > > <html><a href="javascript:;" > onclick="story.closeAllTiddlers();autoSaveChanges()"><input > type="submit" value="Save"></a> > > What am I doing wrong? > > Whole code > > <html><hide linebreaks><!-- see HTMLFormattingPlugin --><form > action="javascript:;" > onsubmit=" > /* validate new title */ > var t=this.title.value; > if (!t.length || t==this.title.defaultValue) > { alert('A title is required'); this.title.focus(); > return false; } > if (store.tiddlerExists(t) && ! > confirm(config.messages.overwriteWarning.format([t]))) > { this.title.focus(); return false; } > > /* 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(); > 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='%0\n' ; > 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); > > /* get new tags and add to existing tags (if any) */ > var newtags=this.tagsfield.value.readBracketedList(); > for (var i=0; i<newtags.length; i++) > tags.pushUnique(newtags[i]); > > /* write and show tiddler */ > store.saveTiddler(t,t,txt, who, when, tags, fields); > story.displayTiddler(story.findContainingTiddler(this),t); > return false;"> > varje inlägg måste ha en unik <b>rubrik</b>, i annat fall kommer det > nya inlägget skriva över det äldre<br> > <input name="title" style="width:50%;" value="" > onfocus="this.select()"><br> > skriv <b>texten</b> till inlägget<br> > <textarea name="field1" rows=5 style="width:100%;"></textarea><br> > <input name="tagsfield" type=hidden value="information"><html><a > href="javascript:;" > onclick="story.closeAllTiddlers();autoSaveChanges()"><input > type="submit" value="Save"></a> > </html> -- 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.

