Top Banner
dajaxproject.com Jorge Bas*da @jorgebas*da jorgebas*da.com
18

djangocon dajaxproject lightning talk

Dec 18, 2014

Download

Technology

Jorge Bastida

My djangocon dajaxproject lightning talk.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: djangocon dajaxproject lightning talk

dajaxproject.comJorge  Bas*da@jorgebas*da

jorgebas*da.com

Page 2: djangocon dajaxproject lightning talk

dajaxproject.com?

Page 3: djangocon dajaxproject lightning talk

dajaxproject.com

•  Set  of  easy  to  use  AJAX  libraries  for  django.

•  django-­‐dajaxice•  communica9on  core.•  send  data  to  your  browser  asynchronously.

•  django-­‐dajax•  manipulate  the  DOM  using  python.

Page 4: djangocon dajaxproject lightning talk

@github

Forks Watchers

django-­‐dajax 6 110

django-­‐dajaxice 10 95

h@ps://github.com/jorgebas*da/django-­‐dajax/h@ps://github.com/jorgebas*da/django-­‐dajaxice/

It’s not enormous, but

I’m

really happy :)

Page 5: djangocon dajaxproject lightning talk

dajaxice  aims

•  Uniform  communica9on  between  the  client  and  the  server.

•  JS  Framework  agnos2c.

•  No  Prototype,  jQuery...  required.

•  Presenta9on  logic  outside  the  views.

•  No  presenta9on  code  inside  ajax  func9ons.

•  Crossbrowsing  ready.

Page 6: djangocon dajaxproject lightning talk

STFU...  Show  me  the  code

Page 7: djangocon dajaxproject lightning talk

Example

from django.utils import simplejsonfrom dajaxice.decorators import dajaxice_register

@dajaxice_registerdef my_example(request): return simplejson.dumps({'message':'Hello World'})

Yes. It’s a function

that returns json

Page 8: djangocon dajaxproject lightning talk

Example

function on_whatever(){ Dajaxice.example.my_example(my_js_callback);}

app name

function name

callback

Page 9: djangocon dajaxproject lightning talk

Example

function my_js_callback(data){ alert(data.message);}

callback

your stuff

Page 10: djangocon dajaxproject lightning talk

Installa@on

{% load dajaxice_templatetags %}

<html> <head> <title>My base template</title> ... {% dajaxice_js_import %} </head>...</html>

automagically

add the

required js *

*  It  could/should  be  served  sta*cally  for  produc*on.

Page 11: djangocon dajaxproject lightning talk

And  django-­‐dajax?

Page 12: djangocon dajaxproject lightning talk

dajax  =  sugar  to  dajaxice

Page 13: djangocon dajaxproject lightning talk

django-­‐dajax

✦  Manipulate  the  DOM  through  python.

✦  Nearly  0  js  knowledge  required.

✦  Supports  some  JS  frameworks  like...

couplingboooo

Page 14: djangocon dajaxproject lightning talk

Internally

Page 15: djangocon dajaxproject lightning talk

the  code

from dajax.core.Dajax import Dajax

def assign_test(request): dajax = Dajax() dajax.assign('#list li','innerHTML','Hello!') dajax.add_css_class('#list li','new') ... return dajax.json()

your actions

Page 16: djangocon dajaxproject lightning talk

the  code

function on_whatever(){ Dajaxice.app.assign_test(Dajax.process);}

Dajax callback

Page 17: djangocon dajaxproject lightning talk

DEMO

Page 18: djangocon dajaxproject lightning talk

Thanks

Jorge  Bas*da@jorgebas*da

jorgebas*da.com