On 8/2/16, António Ramos <[email protected]> wrote: > any demo with web2py?
I'm using it at http://missportuguesa.pt in a simple way. in my first model file: request.pjax = True if request.env.get('HTTP_X_PJAX') == 'true' else False In layout.html: <hrml> <body> (...) <ul class="nav navbar-nav"> <li><a data-pjax href="{{ =URL('index') }}">Home</a></li> <li><a data-pjax href="{{ =URL('some_page') }}">Some page</a></li> </ul> (...) <div id="pjax-container"> {{ block content }} <div class="container">{{ include }}</div> {{ end }} </div> (...) <script src="{{ =URL('static', 'js/jquery.pjax.js') }}"></script> $(document).ready(function() { $(document).pjax('a[data-pjax]', '#pjax-container') }) <body> </html> In default/index.html: {{ extend 'layout.html' if not request.pjax else None }} {{ block content }} {{ # Here in all links I put a data-pjax attribute }} <a data-pjax href="{{ =URL('index') }}>Home</a> {{ end }} Drawbacks I found: - You should take care when using javascript libraries, since the pages are not fully loaded in every request, some references: * https://github.com/defunkt/jquery-pjax/issues/560 * http://stackoverflow.com/questions/9696119/where-to-put-the-page-initialize-javascript-when-using-pjax - Using {{ extend 'layout.html' if not request.pjax else None }} in views you cannot compile views Ricardo -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

