Help me please i'm a newbie in ajax and framework jQuery , i make in jQuery a page , with different plugins a page , but when i receive html code from ajax ,and is not click-able , i used a function live() , but only helped on plugin delete , with edit plugin is not working , what can be the problem...
This is script for editing
<script type="text/javascript">
$(document).ready(function() {
$('.editme').editable('func/update_data.php', {
submitdata: {
type: "<?php echo $page_type?>"
},
cancel: 'Cancel',
submit: 'OK',
tooltip: 'Click to edit...',
id: 'element_id',
name: 'update_value',
});
});
</script>
this is the script for plugin modal window and
$(document).ready(function () {
$('#basicModal input.basic, #basicModal a.basic').click(function (e) {
e.preventDefault();
$('#basicModalContent').modal({
onOpen: function (dialog) {
dialog.overlay.fadeIn('slow', function () {
dialog.data.hide();
dialog.container.fadeIn('slow', function () {
dialog.data.slideDown('slow');
});
});
},
onClose: function (dialog) {
dialog.data.fadeOut('slow', function () {
dialog.container.hide('slow', function () {
$.modal.close();
});
});
}
});
});
$("form#submit_wall").submit(function () {
var message_wall = $('#message_wall').attr('value');
$('#message_wall').val('');
$.ajax({
type: "POST",
url: "func/insert.php",
data: "message_wall=" + message_wall,
dataType: "html",
complete: function () {
$('#basicModalContent').html('<div class="succes"><p>Successful</p> Your record was posted ! </div>');
setTimeout(function () {
$.modal.close()
},
1200);
},
success: function (response) {
$("div#wall").html(response);
//$("div#wall").prepend("<span style='display:none'>"+message_wall+"</span>");
//$("div#wall span").fadeIn();
}
});
return false;
});
});
this is php code for generating html
<?php if(isset($_POST[ 'message_wall'])){
/* Remove HTML tag to prevent query injection */
$message=strip_tags($_POST[ 'message_wall']);
echo '<div class="container_date">
<span style="float: left;">
<p class="editme" id="200">Sex</p>
</span>
<span style="float: right;" align="left">
<a href="javascript:void(0)" id="200" class="delete">Delete</a>
</span>
<br class="clearfloat">
</div>';
} ?>
this is first time for posting on this site , sorry for mistakes and for my english
It is very hard to understand what you want, but it looks to me like this:
You are running $('.editme').editable() only once , when the document.ready event fires. editable() goes through the DOM at that time, and makes all the elements with class "editme" clickable.
When you add a post and get the response from your PHP script through AJAX, the response contains a P tag with class "editme". But since this happens after document.ready has fired, you will need to run editable() again on this new page element to make it clickable.
Big Thanks , i now that is really hard to understand the script , but is my first time to post here , and i have no idea how to ask ,your answer helped me , i put one more time to repeat the editable() inside the php script , response of ajax , and is working !!! ... Big Thanks again !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.