Walter, > Sure, this is something I have struggled with as well. The return from > a Template.evaluate call is not the generated object, but some other > form of return (probably a boolean success or something like that -- > not exactly sure).
`Template.evaluate`[1] doesn't create objects, it generates strings. It accepts an input object and evaluates the template according to the properties on that object, returning the generated string. It has nothing to do with creating elements, although it's frequently used to create HTML strings you might then pass into `Element.update`. But that's just one use; Phil's using it to create a selector. [1] http://api.prototypejs.org/language/Template/ -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Apr 17, 11:45 pm, Walter Lee Davis <wa...@wdstudio.com> wrote: > Sure, this is something I have struggled with as well. The return from > a Template.evaluate call is not the generated object, but some other > form of return (probably a boolean success or something like that -- > not exactly sure). > > If you need to get access to the object immediately after creating it, > you may want to use the new Element() syntax instead of Template, > because this: > > var foo = new Element('div',{id:'bar'}); > > will return a handle to the element, even before you add it to the > page, while Template.evaluate may need you to pause a beat before $ > ('bar') will access the element from your page after you've inserted it. > > Walter > > On Apr 17, 2011, at 2:52 PM, Phil Petree wrote: > > > > > > > > > Using Prototype version 1.6.1 (I know everyone is up to 1.7 but we > > can't upgrade at this time) > > Code looks like this: > > > var selectThis; > > var radioTemplate = new Template('input[type=radio][name=#{selectID}] > > [value=#{selectValue}]'); > > var bValue = 1; // this is actually set from the rc of a function > > and is absolutely 1 but it shouldn't matter > > > selectThis = {selectID: 'owner', selectValue: bValue }; > > $$(radioTemplate.evaluate(selectThis))[0].writeAttribute("checked", > > "checked"); > > the last line causes a throw and all processing stops. any ideas? > > > Thanks, > > > Phil > > > -- > > You received this message because you are subscribed to the Google > > Groups "Prototype & script.aculo.us" group. > > To post to this group, send email to > > prototype-scriptaculous@googlegroups.com > > . > > To unsubscribe from this group, send email to > > prototype-scriptaculous+unsubscr...@googlegroups.com > > . > > For more options, visit this group > > athttp://groups.google.com/group/prototype-scriptaculous?hl=en > > . -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.