Hi Danielo In TiddlyWiki, tiddler objects are immutable; once one has been created the values of the fields cannot be changed. In 5.0.9, that restriction is enforced, but at the moment there's nothing to stop erroneous code modifying a tiddler object.
To modify a tiddler, one instead overwrites the tiddler in the store with a new tiddler with the same title. Here's the crucial line from the function you quoted: self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getCreationFields(),tiddler, updateFields,self.wiki.getModificationFields())); If we separate things out, you can see that the constructor for $tw.Tiddler is being called with four parameters. Each one is a hashmap of field values; they are merged left to right, so that the rightmost field with the same name wins. The resulting tiddler is then passed to addTiddler() to add it to the store. Best wishes Jeremy On Thu, Apr 3, 2014 at 12:53 PM, Danielo Rodríguez <[email protected]>wrote: > Thank you BJ, > > Then, what is the difference between using $tw.wiki.addTiddler(tiddler) > and new $tw.Tiddler() ? > Could you explain me the syntax? > > El jueves, 3 de abril de 2014 10:15:14 UTC+2, BJ escribió: > >> >> HI Danielo, >> with the tw5 code, the Tiddler object is like a house that the actual >> 'tiddler' ocupies. the actual 'tiddler' is known by it name, stored in >> title field. When the 'tiddler' changes in some way it need to change its >> house. the call to new $tw.Tiddler() get a new house for the tiddler. The >> actual 'tiddler' itself is the data inside the old Tiddler object that must >> be copied (and changed) and put in the new Tiddler object. Hope that helps! >> >> cheer >> >> Jeff >> > -- > You received this message because you are subscribed to the Google Groups > "TiddlyWikiDev" 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/tiddlywikidev. > For more options, visit https://groups.google.com/d/optout. > -- Jeremy Ruston mailto:[email protected] -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" 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/tiddlywikidev. For more options, visit https://groups.google.com/d/optout.
