0

i have a status update system in which when a user updates a status people can comment. But the problem is when i click on reply the comment box opens and closes on its own even without giving time to write anything .

there is one code which check when we do a status update and if there is comments (which obviously wont be as we just updated the status it would just hide the commentbox ). and it is somehow effecting the opening of any other clicked comment box . when i remove var t = setTimeout("BpActivityReply()", 325); this line the comment box opens fine but when a new status update it pre opens which should not happen. can anyone suggest where i am wrong

 if (typeof jq == "function") {
jq("#content").ajaxComplete(function (evt, request, settings) {

    var t = setTimeout("BpActivityReply()", 325);
});
jq("div.activity").click(function (event) {
    var target = jq(event.target);
    if (target.hasClass("acomment-reply") || target.parent().hasClass("acomment-reply")) {
        BpActivityReply();
        if (target.parent().hasClass("acomment-reply")) {
            target = target.parent();
        }
        var id = target.attr("id");
        ids = id.split("-");
        var form = jq("#ac-form-" + ids[2]);
        form.parents(".activity-replies").slideDown(200);
        return false;
    }
});
jq(document).keydown(function (e) {
    e = e || window.event;
    if (e.target) {
        element = e.target;
    } else {
        if (e.srcElement) {
            element = e.srcElement;
        }
    }
    if (element.nodeType == 3) {
        element = element.parentNode;
    }
    if (e.ctrlKey == true || e.altKey == true || e.metaKey == true) {
        return;
    }
    var keyCode = (e.keyCode) ? e.keyCode : e.which;
    if (keyCode == 27) {
        if (element.tagName == "TEXTAREA") {
            if (jq(element).hasClass("ac-input")) {
                formContainer = jq(element).parent().parent().parents(".activity-replies");
            }
            if (formContainer.find("ul").length <= 0) {
                formContainer.slideUp(200);
            }
        }
    }
});
BpActivityReply();
 }





function BpActivityReply() {
    jQuery(".activity-replies").each(function () {
        hasComments = jQuery(this).find("ul").first().children("li:visible");
        if (hasComments.length <= 0) {
            jQuery(this).css("display", "none");
        } else {
            jQuery(this).slideDown(200);
        }
    }); 
4

0 回答 0