On Wednesday, October 21, 2015 at 8:33:09 AM UTC+2, Niphlod wrote:
>
> if all you want is not reloading the entire page (before going to "full 
> logic pushed on the client, server just sends the data over") pjax takes 
> maybe 4 lines of code.
>

That was not my experience. I had been using (or abusing) some things that 
work well in standard web2py multi page but not in single page. Some 
examples:
- CKEDITOR needs proper cleanup before you remove the textarea from the 
DOM. Other libraries don't have that problem.
- You have to be careful with the jquery selectors, and/or do cleanup if 
you don't want to pile callbacks to common events. You must understand the 
difference between

$(document).on('click', 'input', callback)
$(#my_form).on('click', 'input', callback)
$('input').on('click', callback)

which is not essential in multi-page, when you are "restarting your app" on 
every call.

- If you don't want to load heavy non-essential libraries many times, you 
want to load them in the proper order, you want some code to run only after 
its dependencies are loaded, but inmediately if they are already loaded, 
etcetera, some work is needed. I trigger a custom jquery event, and attach 
callbacks using $().one('scripts_loaded', callback).

- For some reason, I do have to reload the css files: if I don't remove a 
css link that I added dinamically to head, and reattach it again, most 
libraries don't work. I could research more, for sure.

- You can't upload files via ajax, you can solve it using jquery.form.

- Some ajax callbacks should update the title of the page, and add an entry 
to the browser history, while others don't. Thus the need for crossroads.js 
or page.js

-- 
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.

Reply via email to