locked
clickable row in WebGrid to Modal functionality to clickable cells to a Modal - data no longer passed to page RRS feed

  • Question

  • User379720387 posted

    A webgrid has jquery code attached to open a bootstrap modal when a row is clicked. The modal gets the first cell id of the row and it is used to display some information inside the modal.

    grid.Column("CID", "Id", style: "trclk col1"),
    
                        grid.Column("CFName", "First", style: "trclk col1"),
                        grid.Column("CLName", "Last", style: "trclk col1"),
                        grid.Column("CPhone", "Phone", style: "trclk col1"),
    $(document).ready(function () {
        $('tbody tr , .alternate').on('click', function () {
            $('#detailsModal').removeData('bs.modal');
            $('#detailsModal').modal({
                 keyboard: false,
                 remote: 'DetailsClients/' + $(this).find("td:first").text()
            });
        });
       });

    This all works.

    Now I need one cell of a row excluded from the action to open the modal

    grid.Column("CID", "Id", style: "trclk col1"),
                        grid.Column(format: @<a href="~/Members/EditClient?id=@item.CID">Edit</a>)
                        grid.Column("CFName", "First", style: "trclk col1"),
                        grid.Column("CLName", "Last", style: "trclk col1"),
    $(document).ready(function () {
        $('tbody tr trclk, .alternate').on('click', function () {
            $('#detailsModal').removeData('bs.modal');
            $('#detailsModal').modal({
                 keyboard: false,
                 remote: 'DetailsClients/' + $(this).find("td:first").text()
            });
        });
       });

    I have added "trclk" to each cell that I want a modal opened when clicked and modified the jquery.

    This now works all but the one column that has the EditClient link, open the modal, and the link opens the error page. All fine.

    The only thing that I cannot figure out is why item.CID is no longer passed on to EditClient?

    It starts working again when I remove trclk from the jquery code.

    TIA

    Robert

    Wednesday, October 7, 2015 9:21 AM

Answers