16Jan2012
Mixing Jeditable with a Calendar Thumbnail

Mixing Jeditable with a Calendar

For a recent project I needed to be able to edit text directly on the webpage I decided to use jeditable its very easy to implement and served my needs, but I also needed to add a Jquery UI calendar to the input once generated.

I tried a lot of different ways none of which worked until I came across a githup project called jeditable-datepicker

The default example works well:

$( document ).ready( function() {
 
  var date = $( '.editable' );
 
  date.editable(
    function( value, settings ) {
      date.html( value );
    },
    {
      type: 'datepicker'
    }
  );
 
} );

It how ever does not demonstrate how to save the changes, with a little change saving the changes is easily done.

$(function() {
 
	//editable
	var date = $('.editable');
 
	$('.editable').editable('save.php', {
         indicator : 'Saving...',
         tooltip   : 'Click to edit...',
         type: 'datepicker'
     });
 
});

The changes are sent to save.php via a post. Inside the save file you collect the data then ideally save it, for this example I’m only formatting the data and showing the result back.

<?php 
$value = $_POST['value'];
$id    = $_POST['id'];
 
//format date
$value = date('jS M', strtotime($value));
 
//print the date 
echo $value;
?>

To see this in action have a look at this Demo

Author
Dave

About the Author

has written 74 articles on Dave is my name – Web Developer Blog based in Hull.

My name is David Carr I'm a PHP web developer based in Hull it is my passion to design and develop clean, accessible and usable websites using PHP and other web technologies, I'm an avid Twitter user why not follow me? https://twitter.com/daveismynamecom

Visit this author's website   ·   View more posts by

Sharing is caring.
  • Subscribe to our feed
  • Share this post on Delicious
  • StumbleUpon this post
  • Share this post on Digg
  • Tweet about this post
  • Share this post on Mixx
  • Share this post on Technorati
  • Share this post on Facebook
  • Share this post on NewsVine
  • Share this post on Reddit
  • Share this post on Google
  • Share this post on LinkedIn

Discussion

No responses to "Mixing Jeditable with a Calendar"

There are no comments yet, add one below.

Leave a Comment