What I did was: 

   1. I printed the code of edit-tex widget.
   2. I took some markers and I highlighted the remarkable parts. 
   3. I took a pen and made some notes about what each function did 
   extractin that info from a real TW
   4. I looked into the code of some TW core objects.

After that I think I understood how this works.

My goal is to take a tiddler and clear all its fields except the standard 
ones. At a first instance my flow it was going to be like this:

   1. Take the tiddler from the store.
   2. Copy all its fields to a new temp object
   3. Create a new empty tiddler.
   4. I suppose the empty tiddler has just the standard fields.
   5. Delete those fields from my temp object.
   6. Clear all the fields in the temp object.
   7. Create a new tiddler with this order wiki.addTiddler(new 
   $tw.Tiddler(oldTiddler,tempObject))

But the problem is that the new tiddler has any field. 

El jueves, 3 de abril de 2014 19:18:30 UTC+2, Jeremy Ruston escribió:
>
> 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]<javascript:>
> > 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> 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] <javascript:>
>  

-- 
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.

Reply via email to