Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (39 sloc) 1.47 KB
INSTALL
1. sudo python setup.py install
2. Add 'dajax' in your proyect settings.py inside INSTALLED_APPS
Ej:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'dajax',
...
)
3. Create a new var named DAJAX_MEDIA_PREFIX with the prefix you want to store de ajax functions.
ej: DAJAX_MEDIA_PREFIX="dajax" will create http://yourdomain.com/dajax/...
4. Add a new line in urls.py with this code:
(r'^%s/' % settings.DAJAX_MEDIA_PREFIX, include('dajax.urls')),
5. Create a file named 'ajax.py' inside any django app
6. Inside this file create as many as your want ajax functions.
Ej:
from dajax.core import Dajax
def assign_test(request):
dajax = Dajax()
dajax.assign('#block01 li','innerHTML','Something else...')
return dajax.render()
7. In your settings.py create a new var named DAJAX_FUNCTIONS , this list will contain the name
off all ajax-like callable methods
Ej:
DAJAX_FUNCTIONS = (
'foo.ajax.assign_test',
...
)
7. In your template <header>...</header> include :
<script type="text/javascript" src="/[YOUR DAJAX_MEDIA_PREFIX]/dajax.core.js"></script>
And ensure that prototype was included too above
<script type="text/javascript" src="/static/prototype.js"></script>
8. Now you can invoque your ajax methods using Ej:
onclick="Dajax.foo_assign_test();"
foo will be the name of the package containing ajax.py
9. Enjoy ! ;-)