2011-01-08 9 views
1

私は報告/コメントの報告システムを作成したいと思います。ポップアップをクリックし、クリックしたリンクの情報を入力してください

この時点で、私はちょうどhideidの内側のフィールドにcommentidを送信し、クリックした "フラグ"リンクの隣に表示されるポップを表示します。

<a class="flag" id="[email protected](item.ID)">flag</a> 

と、この私のjqueryのため:

$(".flag").click(function() { 

      var commentId = $(this).attr('id'); 
      $("#comment-id-label").val(commentId); 


      //get the position of the placeholder element 
      var pos = ("#"+commentId).offset(); 
      var width = ("#"+commentId).width(); 
      //show the menu directly over the placeholder 
      $("#menu").css({ "left": (pos.left + width) + "px", "top": pos.top + "px" }); 
      $("#menu").show(); 
     }); 

<div style="position: absolute; display: none;" id="menu"> 
      <input id="comment-id-label" type="text" value="" /> 
</div> 

が、その動作していない任意のアイデア

私は各コメントに沿ってこのようなものを持っている:(How to position one element relative to another with jQuery?から取られましたか)?

+0

あなたは要素のZ-INDEXを確認しましたか? – Nazariy

+0

うん、これは私のリンク上の2番目の答えを使用して作業を得た、プラス他の問題はすでにid = menuで他の何かを持っていた!それは私に頭痛も与えていた! – raklos

答えて

1

jQueryエイリアス$が2か所にありません。

私はいくつかの調整をしたし、仕事にこれを得た:

$(".flag").click(function() { 

    var commentId = $(this).attr('id'), 
     comment = $("#"+commentId); 

    $("#comment-id-label").val(commentId); 

    //get the position of the placeholder element 
    var pos = comment.offset(); 
    var width = comment.width(); 

    //show the menu directly over the placeholder 
    $("#menu").css({ 
     "left": pos.left+width, 
     "top": pos.top 
    }).show(); 
}); 
関連する問題