Search code examples
jquerytwitter-bootstrap-3xpagesxpages-extlib

Application Layout and Bootstrap - adding the navbar-brand element


I have bootstrap enabled for an application via the server theme but I have to find a way to set the anchor with class navbar-brand.

There I added a small scriptblock:

<xp:scriptBlock id="scriptInit">
        <xp:this.value><![CDATA[    
     $(document).ready(function() {        
        $( ".navbar" ).prepend( "<a class='navbar-brand' href='#'>Workflow</a>" );
    });]]></xp:this.value>
    </xp:scriptBlock>

I do not find this the best example but I have not found another way or is there one?


Solution

  • Instead of using a scriptblock, see if you can add the code in the XPage's onClientLoad event (without the document.ready function). If you are using a common custom control (e.g. for the menu, page layout, etc.), you can add the code there, so the change will be in every XPage with that control.