var handleError=function(xhr,text,statusText){ var sessionState=xhr.getResponseHeader('sessionstate'); var errorText=xhr.getResponseHeader('parox_error'); var onConfirm=sessionState==='timeout'? function(){ window.location.reload(); }: $.noop; errorText=errorText?decodeURI(errorText):'对不起,请求服务器发生错误!请稍候再试。'; PAROX.alert({content:errorText,onConfirm:onConfirm}); if(_.isFunction(error)){ error(xhr,text,statusText); } };
createComment:function(attr){ attr.content=PAROX.$.trim(attr.content); if(!attr.content){ PAROX.alert(PAROX.LANG.COMMENT.NULL); return; } attr=this.handleContent(attr); var ctype=this.get('ctype'); attr= _.extend(attr,this.__viewModel.toJSON()); delete attr.parent; this.collection.create(attr,{ wait:true, validate:true, beforeSend:PAROX.showLoading, success: _.bind(function(model){ PAROX.message(PAROX.LANG.COMMENT.SUCCESS); if(this.mentions.length===0)return; this.mentionSomeone(model.get('commentId')); },this), complete:PAROX.hideLoading }); },
createComment:function(attr){ attr.content=PAROX.$.trim(attr.content); if(!attr.content){ PAROX.alert(PAROX.LANG.COMMENT.NULL); return; } var model=new PAROX.models.CommentModel(); attr=this.handleContent(attr); model.save(attr,{ wait:true, validate:true, success: _.bind(function(model){ PAROX.message(PAROX.LANG.COMMENT.SUCCESS); this.parent.fetch(); if(this.mentions.length===0)return; this.mentionSomeone(model.get('commentId')); },this), error:function(){ PAROX.alert(arguments[1].statusText); } }); },
error:function(){ PAROX.alert(arguments[1].statusText); }