I am trying to follow this link: Link to Example
I have the following GridView in a SP Visual Web Part:
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());
// ...
}