I have a .aspx page (vb.net back-end) that I am adding jQuery functions to to decrease postbacks. the page has around a dozen gridviews that are bound to data and have 5 templated field that are not (1 check box and 4 radio buttons per row).
What I am trying to accomplish is jquery functionality that handles changes to the template columns. I have jquery working perfectly, but only if there is one gridview that I am working with. As I stated previously, the page has ~12 gridviews total, all formatted the same and thus need jquery to operate the same. (one option is to replicate what I have 12 times :(…)
I thought that if I could get this to work for two of the twelve, then I’d be set, but I can’t figure it out. I’m very new to jquery and what i do have working is in thanks to these and other message boards. After much searching, using ‘.class’ seems to be the answer to what i am wanting to accomplish, but it is not working as I’d expect.
I’ve taken the html and and what jquery I am trying to get to work and loaded it here to jsFiddler
Can someone take a look and help me get the ‘alert’ for my ‘.class’ to work? If I get this going, I think I may be able to handle the rest of the jquery I will need.
The first two work as expected. The last only works for the first item with the class ‘rbAllNA’:
$(document).ready(function() {
$(rbAllNA1).live('click', function() {
alert($(this).attr('class'));
});
$(rbAllNA2).live('click', function() {
alert($(this).attr('class'));
});
$(".rbAllNA").live('click', function() {
alert("call from class");
});
});
See http://jsfiddle.net/jkmurphy1/68Mpy/1/ for the full scenario.
The problem with you code was
In the first table –
class="rbAllNA"In the second table –
class="rbAllNa"<–a should have been uppercaseYour selector is
$(".rbAllNA")HTML attributes are case sensitive .. So the later won’t work..
Check Fiddle
.live()has been deprecated as of1.7.0.. Attach events using.on()instead.