Instead of

menu = MENU([['name',False,URL('default')]])

do

menu =
MENU([[A('name',_href=URL('default'),_target="_blank"),False,None]])

On Dec 18, 8:11 pm, Bruno Rocha <rochacbr...@gmail.com> wrote:
> Hi,
>
> *I am trying to change every A item of MENU object, including
> target='_blank' attribute,*
> *menu is a '<ul>' tag*
>
> >>> ul = UL(LI(A('test',_href='default')))
> >>> print ul
>
> <ul><li><a href="default">test</a></li></ul>
>
> *I thought I could change MENU in this way:*
>
> >>> ul.elements('a')[0].attributes
>
> {'_href': 'default'}>>> ul.elements('a')[0].attributes['_target'] = '_blank'
> >>> ul.elements('a')[0].attributes
>
> {'_href': 'default', '_target': '_blank'}
>
> *But, I just found that MENU object has not the 'components' attr, why?*
>
> >>> menu = MENU([['name',False,URL('default')]])
> >>> print menu
>
> <ul class="web2py-menu web2py-menu-vertical"><li><a
> href="/powertable/default/default">name</a></li></ul>>>> dir(menu)
>
> [*_?, 'append', 'attributes', 'data', 'element', 'elements', 'flatten',
> 'insert', 'regex_attr', 'regex_class', 'regex_id', 'regex_tag', 'serialize',
> 'sibling', 'siblings', 'tag', 'update', 'xml']>>> menu.elements()
>
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
>   File "/Users/brunomac/web2py/gluon/html.py", line 770, in elements
>     for c in self.components:
> AttributeError: 'MENU' object has no attribute 'components'
>
>
>
> Otherwise, can menu objects have a target attribute?
>
> --
>
> Bruno Rochahttp://about.me/rochacbruno/bio

Reply via email to