Dynamically loading content takes some time to finish. Provide a callback function to load() and use that to manipulate #mydiv.
http://docs.jquery.com/Ajax/load#urldatacallback On Wed, Feb 25, 2009 at 3:16 PM, eagleon <antonypei...@gmail.com> wrote: > > one more thing following the above, ... if I check to see if the > dynamically loaded div exists, it does not.. > > if ( $("#existing_static_div").length > 0 ) { alert(" The ID > exists"); } > > ...will alert that the ID exists... however, > > if ( $("#mydiv").length > 0 ) { alert(" The ID exists"); } > > ...will not fire the alert. Keep in mind, this is despite the fact > that I can see #mydiv getting loaded through firebug, and if I put any > content inside #mydiv (on the remote file, manually), then when I call > it with the load.. the content does appear. However, it seems that > #mydiv technically does not exist.... > > Here is the funny thing.. this only happens with the document ready() > event or load() event... if I attach this to a resize() event for > example, it works fine when I resize the window... > > nt > > On Feb 25, 2:59 pm, eagleon <antonypei...@gmail.com> wrote: >> Code Daemon, I hope you figured it out! I sure haven't yet... >> >> It does not happen to just tables, I tried this with divs, and still >> same result. In my case, I am trying to set the height of a >> dynamically loaded DIV. The load() function applies the height to any >> static div that is already on the page. >> >> Simple example: >> >> $(document).ready(function() { >> $("#existing_static_div").load("filename"); // filename has a div >> called #mydiv, lets say >> $("#mydiv").height('100px'); >> $("#mydiv").css('background', 'red'); >> >> } >> >> Anything I try to perform on #existing_static_div will always work. >> That's a given. However, anything I try to apply to #mydiv, which as >> you see in my example was dynamically loaded... does not work. So, it >> will NOT set the height to 100px and NOT set the background to red. >> >> Any ideas how to overcome this? >> >> Not working in FF or MSIE for me... >> >> On Feb 24, 8:34 am, jQuery Lover <ilovejqu...@gmail.com> wrote: >> >> > Any news on this one ? Code Daemon, what was the problem ? >> >> > ---- >> > Read jQuery HowTo Resource - http://jquery-howto.blogspot.com >> >> > On Thu, Feb 19, 2009 at 3:21 PM, tomasz wawrzyniak <tw.gene...@gmail.com> >> > wrote: >> > > show fragment of your code (javascript) that is executed (and doens't >> > > work >> > > in FF), >> > > and oultine fragment of html that declare the div. >> >> > > 2009/2/19 Code Daemon <ryan.det...@gmail.com> >> >> > >> I hope I'm wrong. I'm not sure what you are asking though. >> >> > >> The page I am loading is just HTML code with a <table> object in it. >> > >> The AJAX server response looks something like: >> >> > >> <table> >> > >> <tr><td></td></tr> >> > >> </table> >> >> > >> It has no <html> tags. Is this necessary? >> >> > >> On Feb 19, 12:46 am, tomasz wawrzyniak <tw.gene...@gmail.com> wrote: >> > >> > That makes no sense - its rather wrong formed html. Did you use Id or >> > >> > Name property to identify webpart? >> >> > >> > On 2/19/09, Code Daemon <ryan.det...@gmail.com> wrote: >> >> > >> > > Seems more specifically that Firefox doesn't like <table> objects >> > >> > > being loaded dynamically. I'm assuming the jQueryload() method is >> > >> > > ultimately a wrapper for the innerHTML property? >> >> > >> > > Looks like, at the very least I'm going to have to omit all my >> > >> > > tables. >> >> > >> > > On Feb 18, 10:56 pm, Code Daemon <ryan.det...@gmail.com> wrote: >> > >> > >> It appears that things work fine in IE, just not Firefox. Very >> > >> > >> strange. >> >> > >> > >> On Feb 5, 6:56 am, jQuery Lover <ilovejqu...@gmail.com> wrote: >> >> > >> > >> > Maybe it's related to wrong content type being sent by your >> > >> > >> > server >> > >> > >> > !!! >> >> > >> > >> > ---- >> > >> > >> > Read jQuery HowTo Resource - http://jquery-howto.blogspot.com >> >> > >> > >> > On Thu, Feb 5, 2009 at 7:42 PM, eagleon <antonypei...@gmail.com> >> > >> > >> > wrote: >> >> > >> > >> > > I've been experiencing the same thing! I hop we can figure out >> > >> > >> > > a >> > >> > >> > > workaround... >> >> > >> > >> > > This also applies to the $(document).ready() event... >> >> > >> > >> > > does not work ondynamicpages..... >> >> > >> > >> > > On Feb 5, 3:21 am, Code Daemon <ryan.det...@gmail.com> wrote: >> > >> > >> > >> But $('#mydiv').load('my/page.html'); works just fine. >> >> > >> > >> > >> On Feb 5, 12:16 am, Dean Barker <framejoc...@googlemail.com> >> > >> > >> > >> wrote: >> >> > >> > >> > >> > look at onLoad() >> >> > >> > >> > >> > <http://www.frameJockey.co.uk> >> >> > >> > >> > >> >www.frameJockey.co.uk >> > >> > >> > >> > i...@framejockey.co.uk >> > >> > >> > >> > framejoc...@gmail.com >> > >> > >> > >> > framejoc...@yahoo.com >> > >> > >> > >> > [image: Google Talk:] framejoc...@gmail.com [image: Y! >> > >> > >> > >> > messenger:] >> > >> > >> > >> > frameJockey >> >> > >> > >> > >> > 2009/2/5 Code Daemon <ryan.det...@gmail.com> >> >> > >> > >> > >> > > When I useload(), it works fine for staticpagesbut doesn't >> > >> > >> > >> > > seem >> > >> > >> > >> > > to >> > >> > >> > >> > > work for mydynamicpage. >> >> > >> > >> > >> > > This is what I'm doing: >> >> > >> > >> > >> > > $('#mydiv').load('my/page'); >> >> > >> > >> > >> > > FireBug shows that the response is coming back just as it >> > >> > >> > >> > > should. >> > >> > >> > >> > > Any >> > >> > >> > >> > > thoughts? >> >> > >> > -- >> > >> > Sent from my mobile device