How to retrieve the TR data on the same row within GridView using JQuery modal window

后端 未结 1 789
悲&欢浪女
悲&欢浪女 2020-12-22 09:11

I am trying to follow this link: Link to Example

I have the following GridView in a SP Visual Web Part:



        
相关标签:
1条回答
  • 2020-12-22 09:37

    Here is how you can make your demo work:

    First, remove the <html> tags from your markup.

    Second remove the onclick="javascript:test();return false;" from your links

    Lastly, change your code to this (demo):

    $(function () {
    
        $('table a').click(function () {
    
            $("#infoShow").html($(".gLine", $(this).closest("tr")).html());
            $("#dialog").dialog({
                title: "View Guideline",
                buttons: {
                    Ok: function () {
                        $(this).dialog('close');
                    }
                },
                modal: true
            });
        });
    
    });
    

    Please note that when you use jQuery UI, include the appropriate version of jQuery.


    Edit: The reason why the code in the question doesn't work is because the onclick is calling test() without any reference to the element. If it looked like this:

    onclick="javascript:test(this);return false;"
    

    then the test function could have done this:

    function test(element) {
        // ...
        $("#infoShow").html($(".gLine", $(element).closest("tr")).html());
        // ...
    }
    
    0 讨论(0)
提交回复
热议问题