You are correct. If you "replace" an element then any handlers
attached to it will be removed.

When you say $('p').click( handleClick ) the "handleClick" function is
_only_ attached to the currently existing "p" elements. If you add
more elements later (or remove and replace an existing element), the
"handleClick" function won't be attached to those new elements.

There are a few solutions:
- "manually" attach the handler to new elements
- use the "liveQuery" plugin ( http://plugins.jquery.com/project/livequery/ )
-  if you're using jQuery 1.3.1 you can look at the new "live"
function ( http://docs.jquery.com/Events/live )

More information here:
http://docs.jquery.com/Frequently_Asked_Questions#Why_do_..._.3F

Karl Rudd

On Mon, Feb 2, 2009 at 10:43 PM, NekraNoX
<rob...@internetessentials.co.uk> wrote:
>
> Hey guys,
>
> Simple problem, really can't see what's wrong with it though:
>
> http://internetessentials.co.uk/clients/ashmoors/products.html
>
> Click "Specifications" on the sub-nav (middle-right of page) and see
> how the content area is changed using show/hide and the links in the
> sub-nav are modified so that "Specifications" is no longer and link
> but "Furniture detail" is.
>
> The idea is that we want "Furniture details" and "Specifications" to
> be toggeled with JQuery. The other links to go to separate pages.
>
> The problem is, if you click "Furniture details" after clicking
> "Specifications" it doesn't trigger the .click() event.
>
> I'm wondering if this is because the object has been modified since
> the page load and can't been effected by the original function
> anymore. Any ideas?
>
> Thanks very much!
>

Reply via email to