cargar la ventana emergente y completar con la información del enlace en el que se hizo clic

I want to create a system of reporting/flagging comments.

At this point Im just getting it to send the commentid to a field inside a hidden div and the pop that div up next to the clicked "flag" link. (taken from :¿Cómo posicionar un elemento en relación con otro con jQuery?)

I have something like this along each comment:

<a class="flag" id="flag-post-@(item.ID)">flag</a>

and this for my 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>

but its not working any ideas?

preguntado el 08 de enero de 11 a las 18:01

Have you checked Z-INDEX of element? -

yep, got this working by using the second answer on the I link posted, plus the other issue was i already had something else with id=menu! so that was giving me a headache too!. -

1 Respuestas

Te estas perdiendo el jQuery alias $ at two places.

I did some tweaking, and got this to work:

$(".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();
});

Respondido el 08 de enero de 11 a las 21:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.