I am trying to change the content of divs, but it seems like after i click the first time, it won't let me change anything else after that. so i will click a link, it will go bold, but then when i try to click another, nothing happens. here is my code:
The reason that's happening is because you're removing the link which you had the event attached to. when you remove that anchor link, you remove the event as well and you have to reattach it.
That doesn't really matter if it's the same or not, think of it this way, easy tag is unique and when you attach an event, you attach it to the tag, you remove that tag you remove everything associated with, including events whether you replaced it with the same text or not. What you'll have to do is store that function to a variable, attach the function by variable name, that at the end of that function, run that same command to attach the event again.
I am still not sure what you mean. i have the tag, <div id="navPane">. this holds the event. that should not change. only what inside should. would you possibly be able to show me with my code, or a short example?
You should look carefully at your code, you attached your event to allnav which is inside navpane, when you do $("#navpane").html you basically emptied out the contents of the tag, events included and replaced it with what you passed to the html function.
so I am basically loosing the attached events with <div id='allNav'>? i guess I am confused, because I don't see the event that is physically attached. i understand that the event is when you click on it, but it should not get overridden, since each link is defined separately. and those links exist in each of the new htmls that are produced.
Yes, you lost the event cause the original element it was attached to was replaced when you did the html call so you'll have to re-register the event with that element. There is no to physically see that you have an event attached to an element, it's more or less registered with the browser itself, is up to you to know that an event should be attached to it since you coded it. If an event is not triggering like it should, it's an indication that the event somehow was unregistered, and you happen to do that when you removed allnav and added it again.
Bookmarks