Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts, .click, names, jQuery

 
Clayton Cramer
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The guy that really knew jQuery left a couple of weeks ago, so I am trying to take over. I have a JSP with a checkbox for ALL hearing types, and then a multibox for selecting one or more of several hearing types. I would like some control over the process, so that when a user unclicks the ALL checkbox, he can go select individual multibox choices, or if he he unclicks one of the multibox choices, it will unclikc the ALL box.

I am not being successful at getting the click function called when the user changes either the ALL checkbox, or any of the multiboxes. Here is the checkbox for ALL.



And the multibox for the different hearing types:



My expectation was that I could write these click event handlers to get control:
While the document ready event handler gets called just fine, these click handlers do not. I have tried a number of combinations of #, ., styleId, without success. There are apparently dozens of different ways to do this--and I just haven't found the right combination. Even worse, the jQuery guru used jQuery a different way every time he did something, so there is no particular pattern to follow. Help!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64844
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please repost the HTML code in question without Struts markup. jQuery (indeed, any JavaScript) operates on the rendered HTML, not the server-side tags.
 
Clayton Cramer
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Please repost the HTML code in question without Struts markup. jQuery (indeed, any JavaScript) operates on the rendered HTML, not the server-side tags.


I presume you mean the source that appears in the browser:



This is what comes out from View Source.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64844
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was more interested in the structural markup.
 
Clayton Cramer
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. My missing jQuery ninja showed up. Then as I explained it, it became obvious: I had moved the click functions outside the ready function, so they weren't being bound.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64844
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah yes... outside the ready handler(s), the DOM hadn't been built yet, so there was nothing to assign the click handlers to.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic