Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.61 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Passing value from edit in line to database
  2. <script type="text/javascript">
  3.  
  4.     $(document).ready(function(){
  5.         $counter = 0;
  6.         $(".editme2").inlineEdit({control: 'textarea'});
  7.         $("#hide").click(function(){
  8.             if ($counter < 10){
  9.                 $counter++;
  10.                 $('#container').show( );
  11.                 $('#container').append( '<div class="inside" style="background: yellow; width: 400px;"><p class="editme2" id="edited'+$counter+'">Click me to add text and drag me to where you want me to be</p></div>');
  12.                 $( '.inside' ).draggable({ containment: '#there' });
  13.             }
  14.         });
  15.     });
  16. </script>
  17.        
  18. <body>
  19.     <button id="hide">Add Text</button>
  20.     <div id="container" align="center" style="display:none; background: blue; width: 600px;">
  21.         </div>
  22.     <div id="there" style="background: red; width: 600px; height: 500px;">
  23.     <h3>drop here</h3>
  24.     </div>
  25. </body>
  26.        
  27. <script type="text/javascript">
  28.  
  29.     $(document).ready(function(){
  30.         // setup common ajax setting
  31.         $.ajaxSetup({
  32.             url: 'save.php',
  33.             type: 'POST',
  34.             async: false,
  35.             timeout: 500
  36.         });
  37.         $(".editme2").inlineEdit({
  38.             control: 'textarea',
  39.             value: $.ajax({ data: { 'action': 'get' } }).responseText,
  40.             save: function(event, data) {
  41.                 var html = $.ajax({
  42.                     data: { 'action': 'save', 'value': data.value }
  43.                 }).responseText;
  44.  
  45.                 alert("id: " + this.id );
  46.  
  47.                 return html === 'OK' ? true : false;
  48.             }
  49.         });
  50.     });
  51. </script>