Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  147] [ 6]  / answers: 1 / hits: 16341  / 14 Years ago, mon, december 6, 2010, 12:00:00

I'm new to writing Javascript, and here's what I'm doing/trying to do.


When a page loads (window.onload) my Javascript code goes through all the forms in a page and attaches a certain onchange method to them. This works fine for most websites on the internet, except when a page dynamically updates to load more forms on the page. How do I detect such an event and re-run my function?


For example:


The Facebook Newsfeed has a bunch of forms associated with all the different statuses/links posted. My code goes through them and attaches the listener. But if go you all the way down the page automatically updates to reveal more statuses/links/etc. (or you click the "Older Posts" link) - but now my javascript code has not run globally again.


Anyway I can do that?


EDIT: I am writing a browser extension.


More From » dom

 Answers
15

use .live() ?



$(document).ready(function()
{
$(document).live(onchange,function()
{
// blah?
});
});

[#94710] Friday, December 3, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
victorw

Total Points: 484
Total Questions: 120
Total Answers: 107

Location: Faroe Islands
Member since Thu, Apr 8, 2021
3 Years ago
victorw questions
Fri, Mar 18, 22, 00:00, 2 Years ago
Sun, Feb 20, 22, 00:00, 2 Years ago
Fri, May 7, 21, 00:00, 3 Years ago
Sat, Mar 13, 21, 00:00, 3 Years ago
;