>
>
> Don't bother your brain with it, a few clicks never kill anyone. It sounds
> easy to mess up for me ;) I will on the other hand be forever grateful if
> you help me with the "sanitizeing" thing. If I understode you right I put
> the code in the last part of the script like this:
>
> submitHandler: function(form, event) {
> event.preventDefault();
> var f = jQuery(form).serializeObject();
> console.log("formData: ", f);
> var tid = new Tiddler( f.title);
> tid.text = f.text;
> tid.modifier = f.username;
> tid.creator = f.username;
> tid.tags = f.tags || [];
>
> store.saveTiddler(tid);
> saveChanges(true, [tid]);
> story.closeTiddler('formTemplate');
> story.displayTiddler(null,' SenasteNytt');
>
> var $title = jQuery('title');
> $title.val($.trim($title.val()));
>
> console.log("tid: ", tid)
> }
>
> But I don't get it to work. Am I doing it wrong?
>
Almost. First of all, you need to do it at the *beginning*, otherwise your
serializeObject method grabs the wrong value.
Also, the selector for the title input doesn't seem right. You can use
either of...
var $title = $("input[name=title]");
//or
var $title = $(".titleInputClass");
//or
var $title = $("#titleInputID");
Assuming that form element either had *name="title"* or a class called
*titleInputClass* or an id called *titleInputID* — use whichever is
appropriate.
To be even more specific — assuming there might be multiple forms — you can
also use...
var $title = $("#formID input[name=title]");
or in your case, you even have the form variable passed to your
submitHandler. So, best use...
var $title = $("input[name=title]", form);
...which translates to "get the *input* with the name of *"title"* within
the element given as the *form* parameter and save that in a variable
called *$title*".
Tobias.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.