Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Added from comment by OP:
Actually when I check outside, jQuery working properly. But here I am using in repeater control in asp.net. Every repeater item template I used one yes/NO item. In that repeater item template wherever only one place yes/NO jQuery working, remaing each item is not working why?

JavaScript
jQuery(function ($) {
    $("a[disabled]").live("click", function () {
        e.preventDefault();
    });
    $(".review-feedbackLink").live("click", function () {
        $(this).addClass("selected");
        $(".review-feedbackLink").attr("disabled", "disabled");
        $(this).parent().after("<span class='thanks'> Thanks for your vote! </span>")
    });
})

ASP.NET
<asp:Repeater ID="repeat" runat="server" OnItemDataBound="repeat_ItemDataBound">
<HeaderTemplate>
    <table style=" border:1px solid #C9C9C9; width:500px" cellpadding="0" class="back_table">
    <tr>
        <td colspan="1" class="title_comments">
            <b>Reviews</b>
        </td>
    </tr>
    </table>
</HeaderTemplate>
<ItemTemplate>
    <tr>
        <td>
            <div class="review-footer-new">
                <p class="review-feedbackQuestion">
                    Was this review helpful?
                    <a href="#">
                        <span class="review-feedbackLink login-required" data-rating="1">
                            <span class="review-feedback-isHelpful"></span> Yes
                        </span>
                    </a>
                    <a href="#">
                        <span class="review-feedbackLink login-required" data-rating="0">
                            <span class="review-feedback-isNotHelpful"></span> No
                        </span>
                    </a>
                </p>
            </div>
        </td>
    </tr>
</ItemTemplate>
</asp:Repeater>
Posted
Updated 24-Feb-15 2:38am
v2
Comments
Member 10918596 24-Feb-15 7:45am    
actually when i check outside, jquery working properly.but here i am using in repeater control in asp.net.every repeater item template i used one yes/NO item.in that repeater item template wherever only one place yes/NO jquery working,remaing each item is not working why?

1 solution

When you click on a single "Yes / No" link, your script is disabling every feedback link on the page. I suspect you only want to disable the links for the specific item you've clicked on.

Try something like this:
JavaScript
// NB: As of jQuery 1.7, "live" is deprecated in favour of "on":
// http://api.jquery.com/live/
// http://api.jquery.com/on/

$(".review-feedbackLink").on("click", function () {
    
    // Needed to prevent clicking disabled links:
    if ($(this).closest("a").is("[disabled]")){ return false; }
    
    $(this).addClass("selected");
    $(this).parent().after("<span class='thanks'> Thanks for your vote! </span>");
    
    // Walk up the tree to the nearest feedback question;
    // then find all feedback links within that question;
    // then find the parent <a> tag for the link and disable it.
    $(this)
        .closest(".review-feedbackQuestion")
        .find(".review-feedbackLink")
        .closest("a")
        .attr("disabled", "disabled");
});
 
Share this answer
 
Comments
Member 10918596 24-Feb-15 23:15pm    
thank u ....i got answer..very nice....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900