hola tengo mi codigo ajax de javascript el cual no me funciona del un campo input y textarea
Código Javascript
:
Ver originalvar muro = {
show_comment_box: function(id){
$('#cb_' + id).show()
},
comentar: function(id){
var val = $('#cf_' + id).val();
muro.stream.status = 1;
if(val == '' || val == $('#cf_' + id).attr('title')) {
$('#cf_' + id).focus();
// LOADER/ STATUS
muro.stream.loader(false);
muro.stream.status = 0;
return false;
}
//
$.ajax({
type: 'POST',
url: global_data.url + '/muro-coment.php?do=repost',
data: 'data=' + encodeURIComponent(val) + '&pid=' + id,
success: function(h){
switch(h.charAt(0)){
case '0': //Error
mydialog.alert('Error:', h.substring(3));
break;
case '1': //OK
$('#cl_' + id).append(h.substring(3));
$('#cf_' + id).val('');
break;
}
},
complete: function (){
// STATUS
muro.stream.status = 0;
}
});
},
}
/** READY **/
$(function(){
// RESPUESTAS
$('.comentar').css('max-height', '200px').autogrow().css('height','14px');
//
$('input[name=hack]').live("focus",function(){
$(this).hide();
$(this).parent().find('div.formulario').show();
var pub_id = $(this).attr('pid');
//
$('#cf_' + pub_id).focus()
})
});
codigo el cual quiero que cuando comente escriban dentro de campo den a la tecla enter y me haga el ajax insertando un comentario
Código PHP:
<li class="ufiItem">
<div class="newComment">
<input type="text" class="ui-corner-all form-input-text box-shadow-soft" name="hack" placeholder="Escribe un comentario..." pid="<?php echo $row['pub_id']; ?>" />
<div class="formulario" style="display:none">
<img src="<?php echo $this->tsConfig['url'];?>/files/avatar/<?php echo $this->tsUser->uid ?>_50.jpg" width="32" height="32"/>
<textarea class="comentar ui-corner-all form-input-text box-shadow-soft" placeholder="Escribe un comentario..." id="cf_<?php echo $row['pub_id']; ?>" pid="<?php echo $row['pub_id']; ?>" name="add_wall_comment"></textarea>
<div class="clearBoth"></div>
</div>
</div>
</li>