New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: HTML

Simple MVC Example of inline Delete Button with hidden id field

41 Views
Copy Code Show/Hide Line Numbers
<% for (int i = 0; i < 10; i++) { %>
    <div class="emailAddress">
        <label>jimbo@example.com</label>
        <%= Html.Hidden("asdf", Guid.NewGuid()) %>
        <a href="javascript:void(0);">Delete</a>
    </div>
<% } %>
    
    
<script type="text/javascript"> 
    $(document).ready(function() {
        $(".emailAddress").each(function(i, el) {
            var anchor = $(el).children("a").get(0);
 
            // Assign click handler
            $(anchor).click(function() {
                var hidden = $(anchor).siblings(":input[type='hidden']").get(0);
                alert(hidden.value);
            });
        });
    });
</script>
by jwwishart
  January 13, 2010 @ 9:31pm

Add a comment


Report Abuse
brought to you by:
West Wind Techologies


If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate