Try function setup() { $("a.showHidePrograms").click( function () { var $div= $(this).parent().next("div"); if($div.attr("class") == 'hide'){ $div.attr("class","show"); }else{ $div.attr("class","hide"); } } ); } $(document).ready(function(){ setup(); });
Then in your ajax method target.appendJavascript("setup();"); On Fri, Apr 9, 2010 at 5:30 PM, Russell Morrisey < russell.morri...@missionse.com> wrote: > It might be a good idea to use an IBehavior to contribute the script. You > can add the behavior to the link component in wicket; when the behavior is > rendered, it can contribute the javascript code to set it up with jquery. > That way, you ensure that every new rendering of the link (which creates a > new DOM element) includes your javascript (which binds your handler to the > DOM element that is there right now), whether it's the first time on the > page or from an ajax request. When you bind your event on page load, the > ajax request creates a new DOM element for the link by repainting it, so the > link that had your bound event handler goes away. > > > RUSSELL E. MORRISEY > Programmer Analyst Professional > Mission Solutions Engineering, LLC > > | russell.morri...@missionse.com | www.missionse.com > 304 West Route 38, Moorestown, NJ 08057 > > -----Original Message----- > From: tubin gen [mailto:fachh...@gmail.com] > Sent: Friday, April 09, 2010 2:12 PM > To: users > Subject: jqery not getting called after ajax refresh > > I added this jquery code to my page. > > $(document).ready(function(){ > $("a.showHidePrograms").click( > function () { > var $div= $(this).parent().next("div"); > if($div.attr("class") == 'hide'){ > $div.attr("class","show"); > }else{ > $div.attr("class","hide"); > } > } > ); > }); > > inside my html I have a table this contains anchor tag with > class showHidePrograms. > onclick of this anchor tag the function gets called everything is fine. > > This page also has some ajaxLinks on click of this link I repaint the > table, after this when I click on anchor tag the jquery script is not > called , > does repainting somehow hides this anchor from jquery ? > > This is a PRIVATE message. If you are not the intended recipient, please > delete without copying and kindly advise us by e-mail of the mistake in > delivery. > NOTE: Regardless of content, this e-mail shall not operate to bind MSE to > any order or other contract unless pursuant to explicit written agreement or > government initiative expressly permitting the use of e-mail for such > purpose. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >