js[周六代码分享]:爱问回答修改答…

本文详细介绍了使用JavaScript修改爱问平台回答的实现方式,包括获取原始回答内容、创建对话框进行编辑、提交修改以及更新页面内容等关键步骤。
JavaScript语言: <wbr></wbr> 爱问回答修改答案的js方法
case 'editreply':
$("#editquotelink").val($("#quote_"+id).html()); 
//$('#editreply').val($('#post_'+id).html());
var old_reply = $('#post_'+id).html();
$("#editreply_div").iDialog({
title:'{langask_input_addtional}',
 width:500,
 height:'auto',
 submit:function(){ 
 //vareditreply =document.getElementByIdx_x('editreply').value;
 var editreply = editor['editreply'].getContent();
 var editquotelink = document.getElementById('editquotelink').value;
 if( !(editor['editreply'].hasContents())) {
 $("body").iTips({content:'{langask_null_enter}',css:'notice'});
 return false;
 }
 var url = '{$_G[PHP_SELF]}?mod={$_G[mod]}&do=action&act=editreply&postid='+id;
 $.post(url,{editreply:editreply,editquotelink:editquotelink},function(data){
 if(data.IsSuccess){
 $("body").iTips({content:'{langask_modify_success}',css:'success'});
 $("#editreply_div").dialog('close');
 $("#post_"+id).html(editreply);
 if(editquotelink!=''){
 $("#quotelink_title_{$replylist['postid']}").removeClass();
 $("#quote_"+id).html(editquotelink);
 }else if(data.isLocked){
 $("body").iTips({content:'{langask_post_locked}',css:'warning'});
 }else{
 $("body").iTips({content:'{langask_modify_failure}',css:'error'});
 }
 }
 },'json')
 } 
});
setTimeout(function(){
 //设置编辑器的内容为之前回答的内容
 editor['editreply'].setContent(old_reply); 
 //让编辑器在最顶层显示
 $("#editreply").children().css("z-index",10000); 
}, 1000);
break;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值