On Thu, Jan 05, 2006 at 02:58:02PM -0600, Peter Speltz wrote:
> On 1/5/06, Peter Speltz <[EMAIL PROTECTED]> wrote:
> > [%#
> >
> > =head2 set_selected
> >
> > Set which option in the select box element is selected based on value.
> > "element" is an HTML::Element object of type select.
> >
> > =cut
> >
> > %]
> >
> > [% MACRO set_selected(element, value) BLOCK;
> >     FOR opt IN element.content_list;
> >
> >         IF opt.attr('value') != value;
> >             opt.attr('selected', undef);
> >         ELSIF opt.attr('value') == value;;
> >             opt.attr('selected', 'selected');
> # BUG  Above line. add this in front "SET myval = " .
> >             LAST;
> >         END;
> >     END;
> > END;
> > %]
> >
> 
> Bug in above. It gets me every time.  Since HTML::Element returns a 
> value when you change/set (not sure exact details) an attribute, you
> get this phantom 'selected'  showing up on the page when using the
> macro. Catch that value like this when you set attributes.   Above I
> commented .
> 
> SET myval =  opt.attr('selected', 'selected');

I long since adopted

  xx = opt.attr(...);

as a standard throughout my TT stuff; it seemed as clearly meaningless but
doesn't break up the flow to the eye so much.

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Maypole-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-users

Reply via email to