SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    976
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    window.load equivalent with jquery .getScript

    I'm loading a script into the page with the .getScript() function. Some content is being loaded as well (some of which are images). I need to do some stuff with this content but it doesn't seem to exist. For instance I put a function in the file being loaded and then fire it in the callback of getScript and get something in the console that says the function doesn't exist. Also, when I try to go through the images, they're not attached to the DOM or something because they're don't have a method 'offset'.

    for instance, bottom of the page being loaded:
    Code:
    <script type="text/javascript" charset="utf-8">
    	$(document).ready(function() {
    		$.getScript('/assets/file_list.js', function(data, textStatus) {
    			// callbacks
    			resizeInfoPanel( $('.file_list > li') );
    		});
    	});
    </script>

    file_list.js
    Code:
    	function resizeInfoPanel(image_collection) {
    		console.log(image_collection);
    	}
    any help is appreciated.
    your brain reacts in the same way whether you are
    looking at something or thinking about it...

  2. #2
    SitePoint Enthusiast Anthony.Barnes's Avatar
    Join Date
    Aug 2011
    Location
    Canberra, Australia
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That same code works fine for me when I stick it into a basic template on my local PC (tested jQuery 1.6.2+). Perhaps the issue isn't related to getScript().


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •