我尝试在满足可变更改后进行更新,并且下面的代码适用于"点击"等事件,而不是"焦点","更改&#34 ;等等。
寻找一种合理的方式来运行ajax更新,而不是每次点击或类似的事情。
有没有办法从contenteditable触发这些事件?
$("#resume_holder").contents().on("click", function(e) {
var txt = $(e.target).closest("section").html();
var id = $(e.target).closest("section").attr('id');
alert(txt+' '+id);
$.ajax({
type : 'POST',
url : '<?php echo site_url('resume/edit_resume_ajax'); ?>',
data: {
edit_id : id,
edit_value: txt
},
success : function(msg){
},
error: function(){
}
});
});
答案 0 :(得分:1)
部分问题是iframe没有准备好。以下代码有效:
<script>
$(document).ready(function() {
$("#resume_holder").ready(function () {
$('#resume_holder').contents().find('[contenteditable]').on("blur", function(e) {
var txt = $(e.target).closest("section").html();
var id = $(e.target).closest("section").attr('id');
$.ajax({
type : 'POST',
url : '<?php echo site_url('resume/edit_resume_ajax'); ?>',
data: {
edit_id : id,
edit_value: txt
},
success : function(msg){
},
error: function(){
}
});
});
});
});
</script>