
Untitled
By: a guest on
May 8th, 2012 | syntax:
None | size: 1.61 KB | hits: 8 | expires: Never
Passing value from edit in line to database
<script type="text/javascript">
$(document).ready(function(){
$counter = 0;
$(".editme2").inlineEdit({control: 'textarea'});
$("#hide").click(function(){
if ($counter < 10){
$counter++;
$('#container').show( );
$('#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>');
$( '.inside' ).draggable({ containment: '#there' });
}
});
});
</script>
<body>
<button id="hide">Add Text</button>
<div id="container" align="center" style="display:none; background: blue; width: 600px;">
</div>
<div id="there" style="background: red; width: 600px; height: 500px;">
<h3>drop here</h3>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
// setup common ajax setting
$.ajaxSetup({
url: 'save.php',
type: 'POST',
async: false,
timeout: 500
});
$(".editme2").inlineEdit({
control: 'textarea',
value: $.ajax({ data: { 'action': 'get' } }).responseText,
save: function(event, data) {
var html = $.ajax({
data: { 'action': 'save', 'value': data.value }
}).responseText;
alert("id: " + this.id );
return html === 'OK' ? true : false;
}
});
});
</script>