jquery-pjax

110 views
Skip to first unread message

Carlos Cesar Caballero Díaz

unread,
Jun 14, 2016, 8:34:22 AM6/14/16
to web...@googlegroups.com
Hi everyone, have you any experience with
https://github.com/defunkt/jquery-pjax and web2py? it looks really
interesting.

Greetings.

--
Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

Niphlod

unread,
Jun 14, 2016, 10:48:44 AM6/14/16
to web2py-users
great, simple, done.

Massimo Di Pierro

unread,
Jun 18, 2016, 9:04:28 AM6/18/16
to web2py-users
Nice library.  It is a lot like web2py components but better. Perhaps web3py should use pjax.js

António Ramos

unread,
Aug 2, 2016, 1:36:25 PM8/2/16
to web...@googlegroups.com
any demo with web2py?

--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ricardo Pedroso

unread,
Aug 2, 2016, 3:04:08 PM8/2/16
to web...@googlegroups.com
On 8/2/16, António Ramos <ramst...@gmail.com> 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

Dave S

unread,
Aug 2, 2016, 5:11:21 PM8/2/16
to web2py-users


On Tuesday, August 2, 2016 at 12:04:08 PM UTC-7, Ricardo Pedroso wrote:
On 8/2/16, António Ramos <ramst...@gmail.com> wrote:
> any demo with web2py?

I'm using it at http://missportuguesa.pt in a simple way.

[detailed example]

Thanks, your code looks good (clear!) and the pjax readme at the github site is also straightforward (he says before trying it).

The Mozilla pages on the history API seem like good background reading, so that us borrowers have a clue what's happening under the hood.
<URL:https://developer.mozilla.org/en-US/docs/Web/API/History_API>
They link to an example; a couple of other simple examples are at
<URL:http://html5.gingerhost.com/>
<URL:https://css-tricks.com/using-the-html5-history-api/ >
(My history now includes "developer.mozzilla.org/dangit" from opening the console, and typing the obvious "history.pushstate(null, null, '/dangit'))

/dps

António Ramos

unread,
Aug 11, 2016, 9:23:18 AM8/11/16
to web...@googlegroups.com
pjax without jquery dependency

https://github.com/MoOx/pjax

--
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+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages