Flickr in place editor
Explanation
In this example we will create a in place editor inspired in flickr.
ajax.py
from dajax.core import Dajax
from dajaxice.decorators import dajaxice_register
@dajaxice_register
def flickr_save(request, new_title):
dajax = Dajax()
dajax.script('cancel_edit();')
dajax.assign('#title','value',new_title)
dajax.alert('Save complete using "%s"!' % new_title )
return dajax.json()
html
Javascript
function toggle_editor(){
if(!$('title').hasClassName('editing')){
$('title').addClassName('editing');
$('title').select();
$('tools').show();
}
}
function cancel_edit(){
$('tools').hide();
$('title').removeClassName('editing');
$('title').blur();
}
function save(){
new_title = $('title').value;
$('title').value = "saving...";
Dajaxice.examples.flickr_save(Dajax.process,{'new_title':new_title});
}

Examples

Download
Documentation
Bugs