Melhorar função de comentários

  • Autor Autor ChatOrbi
  • Data de início Data de início
Tradução em andamento: em alguns minutos este tópico estará em português. Por enquanto, o conteúdo está no original em espanhol. Ver original
ChatOrbi

ChatOrbi

Épsilon
920oHNe.png


Cuando envio un nuevo comentario el cuadro para realizar el mensaje siempre sale.

Como hago que se quite cuando el mensaje se ha enviado?

PHP:
function comment_form($stream_id, $flag = '') {
	global $config, $client;
	if (!$client['id']) {
		return '<div>&gt;&gt;'.url('member/login',t('Login to comment') ).'</div>';
	}
	if (!$flag) $flag = t('Comment');
	if (!$config['comment_headed']) {
		$comment_head =  
		'
				<script>
				$(document).ready( function(){
                                                
                                                $("a[class=comment_delete]").click( function () {
var parentdd = $(this).parents(".user_comment");
var sid = $(this).prev()[0].value;
$(this).after("<img src=\''.uhome().'/files/loading.gif\' /> hiding..");
$(this).hide();
$.get(\''.uhome().'/index.php?p=jquery/comment_delete/\'+sid, function(data) {
parentdd.hide("slow");
});
return false;
});
						$(".quick_comment").click(function() {
								$(this).next().next().css("display","block");
								$(this).next().next().find(".commentmessage").focus();
								return false;
						});
						$(".commentsubmit").click(function() {
							if ($(this).prev()[0].value != "") {
								var thiscomment = $(this).parents(".quick_comment_form");
								var cbox = thiscomment.next().next();
								var mbox = thiscomment.find(".commentmessage");
								var tbox = thiscomment.next();
								cbox.html("<img src=\"'.uhome().'/files/loading.gif\" /> Submitting");
								$.post("'.uhome().'/index.php?p=jquery/comment_publish",
								{message:mbox[0].value,target_id:tbox[0].value},
								  function(data){
									cbox.html("");
									cbox.after(data);
									mbox.attr("value","");
									},"html"
								);
								return false;
							}
						});
						$(".dolike").click(function() {
							var thiscomment = $(this).next();
							var cbox = thiscomment.next().next();
							var tbox = thiscomment.next();
							cbox.html("<img src=\"'.uhome().'/files/loading.gif\"/> Submitting");
							$.post("'.uhome().'/index.php?p=jquery/dolike",
							{target_id:tbox[0].value},
							  function(data){
								cbox.html("");
								cbox.after(data);
								},"html"
							);
							$(this).css("display","none");
							return false;
						});
				});
				</script>
				';
			$config['comment_headed'] = 1;
	}
	$res = sql_query("select * from ".tb()."liked where stream_id='$stream_id' and uid='{$client['id']}' limit 1");
	if (sql_counts($res)) {
		$likeit = '<a href="#" class="dolike">'.t('Unlike').'</a>';
	}
	else {
		$likeit = '<a href="#" class="dolike">'.t('Like').'</a>';
	}


		return $comment_head.'
		<div>
		<a href="#" class="quick_comment">+'.$flag.'</a> | '.$likeit.'
			<div class="quick_comment_form" style="display:none;">
				<table border="0"><tr><td valign="top">
				<img src="'.uhome().'/uploads/avatars/s_'.$client['avatar'].'" width="25" height="25" />
				</td><td>
				<textarea name="message" rows="2" class="fpost commentmessage""  style="width:350px;" ></textarea>
				<input type="button" value=" '.$flag.' " class="fbutton commentsubmit" />
				</td></tr>
				</table>
			</div>
			<input type="hidden" name="wall_id" value="'.$stream_id.'" />
			<div></div>
		</div>';
		}

alguien me puede ayudar?
 
Foi útil? Participe da conversa

Com sua conta grátis você pode responder, mandar mensagem privada ao autor e comprar com Saldo retido: o pagamento é liberado quando você recebe o combinado.

Leva 30 segundos · você volta a este tópico ao terminar

PHP:
if($_POST['message']==""){
return $comment_head.'
        <div>
        <a href="#" class="quick_comment">+'.$flag.'</a> | '.$likeit.'
            <div class="quick_comment_form" style="display:none;">
                <table border="0"><tr><td valign="top">
                <img src="'.uhome().'/uploads/avatars/s_'.$client['avatar'].'" width="25" height="25" />
                </td><td>
                <textarea name="message" rows="2" class="fpost commentmessage""  style="width:350px;" ></textarea>
                <input type="button" value=" '.$flag.' " class="fbutton commentsubmit" />
                </td></tr>
                </table>
            </div>
            <input type="hidden" name="wall_id" value="'.$stream_id.'" />
            <div></div>
        </div>'; 
}

como lo unico que das es la funcion de mostrar el form... en teoria eso seria tu solucion
 
En el código que pones, la linea cbox.html(""); borra el contenido del cuadro de texto. debería funcionar bien.
¿Te da algún error javascript?
 
En el código que pones, la linea cbox.html(""); borra el contenido del cuadro de texto. debería funcionar bien.
¿Te da algún error javascript?

No funciona

¿Tengo que colocar algun codigo en javascript en el formulario?
 
Agrega

Inserir CODE, HTML ou PHP:
$(".quick_comment_form").hide();
 
No has respondido a mi pregunta: ¿Da algún error javascript? Sin eso no podemos ayudarte mucho.
 
al final de
Inserir CODE, HTML ou PHP:
 $(".commentsubmit").click(function() {
 
Sigues sin indicar el error... 😛
 
Voltar
Topo