natecavanaugh/alloy-ui — pull request #101 by marclundgren (2012-08-31 21:24:28+00:00)
Title: AUI-707 TreeNode has no default value set for "id"

Hey Nate,

I tried this first:

id: {
validator: isString,
valueFn: A.guid
}

but it was causing the demo not to work. Looking at the other ATTRs with a valueFn, I noticed they were all anonymous fns that returned a value. Tried it out and it worked. Although I'm not 100% sure why.

In the initializer I was just simple checking to see if instance.get('id') was set. It was set to root1 or something. But then we only ran thru the initializer once if I was using valueFn: A.guid...

Then when I set it to what you see now, I saw the initializer run for each sub tree - which I'm assuming is what it should have been. It just bugs me that I don't know WHY your way didn't work.