2012-01-09 15 views
1

であれば、私はおそらく何かは、ユーザーが、私はあなたが私を与え、これをした答えを取ったが、それは仕事をdoesntの[OK]をテキストエリアに

function setusersintext(inout){ 
    var userIsInTextArea = false; 
    if($inout=='in'){ 
     userIsInTextArea = true; 
    }else{ 
     userIsInTextArea = false; 
    } 
    } 

    $(".refreshMe").everyTime(5000,function(i){ 
     if(!userIsInTextArea) { 
     $.ajax({ 
      url: "refresh-me.php?id=<?php echo $get_id['id']; ?>&user=<?php echo $user; ? >&user_name=<?php echo $user_name; ?>", 
      cache: false, 
      success: function(html){ 
      $("ol#newupdates").prepend(html); 

      } 
     }) 
     } 
    }) 

をしないのです時間による更新を一時停止することができ、ここでテキストエリアコードがあります。

<textarea name="comment" class="comment" maxlength="200" 
     id="ctextarea<?php echo $msg_id;?>" 
     onfocus="myFocus(this);setusersintext(in);" 
     onblur="myBlur(this);setusersintext(out);"> 
    Write a comment... 
</textarea> 

答えて

2

ユーザーがフォーカスをテキスト領域に設定し、そのフラグを後で確認するときにフラグを設定するだけです。こうした迅速な答えを

var userIsInTextArea = false; 

$('#commentText').focus(function() { 
    userIsInTextArea = true; 
}); 

$('#commentText').blur(function() { 
    userIsInTextArea = false; 
}); 



    $(".refreshMe").everyTime(5000,function(i){ 
     if(!userIsInTextArea) { 
     $.ajax({ 
      url: "refresh-me.php?id=<?php echo $get_id['id']; ?>&user=<?php echo $user; ?>&user_name=<?php echo $user_name; ?>", 
      cache: false, 
      success: function(html){ 
      $("ol#newupdates").prepend(html); 

      } 
     }) 
     } 
    }) 
+0

本当にありがとうございました。今すぐテストしてみると、すぐに対応します。 –

+0

私はもう1つの質問があります...テキストエリアコードはここにあります ように、ID = "ctextarea +メッセージIDは、彼らはコメントAJAXを更新するかを知って提出 ...道にはあり...コメントを書きます?別のIDが使用さ –

+0

を持っているか、というのonblur ONFOCUSはそんなにトップのおかげでテキストエリアコードトリガー何かに使用されていることができ –

関連する問題