Nevermind, I have extract header of every layout I have anyway into header.html that I include back in each layout so, my app stay DRY.
I am glad I had issue with selecting navbar jquery injected element that I can't select with selenium/splinter as it allow me to figure an new way to include my tag by user membership... Doing it like you propose prevent me from making a select to check if user is member of the proper group, reducing page load time... One less select!! :) Richard On Mon, Apr 10, 2017 at 4:07 PM, Richard Vézina <ml.richard.vez...@gmail.com > wrote: > Hello Anthony, > > Is there a way to manipulate auth.navbar content from model file somehow > avoiding repeat this in every layout file I have? > > Thanks > > Richard > > On Sun, May 24, 2015 at 9:55 AM, Neeraj Shukla <neerajdshu...@gmail.com> > wrote: > >> Thanks Anthony... >> >> >> On Sunday, 24 May 2015 03:16:00 UTC+5:30, Anthony wrote: >>> >>> Your code is incorrect. Instead of inserting the full navbar object, you >>> apply a string of methods to it and insert the return value of the final >>> method (which is None). As in the original code example, you must assign >>> the navbar to a variable, then apply the manipulation, and finally insert >>> the edited navbar: >>> >>> {{navbar = auth.navbar(mode='dropdown') >>> if auth.user: >>> navbar.element('ul.dropdown-menu').components.extend([LI('Item 1' >>> ), LI('Item 2'), ...])}} >>> {{=navbar}} >>> >>> Anthony >>> >>> On Saturday, May 23, 2015 at 12:00:23 PM UTC-4, Neeraj Shukla wrote: >>>> >>>> >>>> <https://lh3.googleusercontent.com/-OK9lM0zgP4c/VWCkDG6uOUI/AAAAAAAAALs/RjjEwoaloSc/s1600/web2py_query.png> >>>> >>>> >>>> <https://lh3.googleusercontent.com/-OK9lM0zgP4c/VWCkDG6uOUI/AAAAAAAAALs/RjjEwoaloSc/s1600/web2py_query.png> >>>> >>>> Following code I used and it produces None in HTML markup >>>> {{=auth.navbar(mode='dropdown').element('ul.dropdown-menu').components.extend([LI('Item >>>> 1'), LI('Item 2')])}} >>>> >>>> >>>> Couldnt figure it out. >>>> >>>> On Saturday, 23 May 2015 19:16:44 UTC+5:30, Anthony wrote: >>>>> >>>>> Hmm, seems to work for me. Can you show your exact code as well as the >>>>> HTML markup that ends up in the browser? >>>>> >>>>> On Saturday, May 23, 2015 at 6:01:34 AM UTC-4, Neeraj Shukla wrote: >>>>>> >>>>>> >>>>>> navbar = auth.navbar(mode='dropdown') >>>>>> if auth.user: >>>>>> navbar.element('ul.dropdown-menu').components.extend([LI('Item 1' >>>>>> ), LI('Item 2'), ...]) >>>>>> >>>>>> Above method is not working on web2py 2.10.4 >>>>>> >>>>>> however jquery works. >>>>>> For example >>>>>> {{block page_js}} >>>>>> {{if auth.user:}} >>>>>> <script> >>>>>> jQuery("ul.dropdown-menu").append('<li>item 1</li>'); >>>>>> </script> >>>>>> {{pass}} >>>>>> {{end page_js}} >>>>>> >>>>>> However, use of javascript may slowdown page loading. Can anyone >>>>>> please suggest better working approach for mentioned web2py version ? >>>>>> On Tuesday, 30 April 2013 20:50:52 UTC+5:30, ctrlSoft wrote: >>>>>>> >>>>>>> hi, how to add items in >>>>>>> <ul class="dropdown-menu" style="display: block;"> >>>>>>> ... >>>>>>> ... >>>>>>> ... >>>>>>> </ul> >>>>>>> generated by auth.navbar(mode="dropdown"), >>>>>>> >>>>>> -- >> Resources: >> - http://web2py.com >> - http://web2py.com/book (Documentation) >> - http://github.com/web2py/web2py (Source code) >> - https://code.google.com/p/web2py/issues/list (Report Issues) >> --- >> You received this message because you are subscribed to the Google Groups >> "web2py-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to web2py+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.