logo
examples Examples
  • Random machine
  • Multiply example
  • Simple Form
  • Django Forms
  • Map example
  • Flickr in place editor
  • Pagination example

dajaxproject

django+ajax

Flickr in place editor

  OR  
image

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

		
OR
image

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});

		}
	
downloads Download   documentation Documentation   bugs Bugs
mail Any issues? Join our mailing list now!
Copyright © 2010 Jorge Bastida | icons by Joseph Wain