Results 1 to 4 of 4

Thread: jQuery JS Load in a Div Help

  1. #1
    Join Date
    Aug 2006
    Location
    UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default jQuery JS Load in a Div Help

    Hi,
    I really need some help with this, I have a function that automatically generates a bulleted list of thumbnails;

    Code:
    function thumbs_getItemHTML(item)
    {
        var url_m = item.link;
        return '<a href="' + url_m + '" title="' + item.title + '"><img src="' + item.url + '" width="152" height="80" border="0" alt="' + item.title + '" /></a>';
    };
    item.title & item.url are variables defined earlier in the script.

    What I am try to do is make these thumbnails open in a DIV, on the same page. The DIV is called mainImage (surprisingly). I was wondering if someone could help me, as all current methods of functionality I have found tend to break becuase of the way my URLs are defined.

    I was looking at adding something like this;
    Code:
    function loadContent(elementSelector, sourceUrl) { 
      $(""+elementSelector+"").load("http://yoursite.com/"+sourceURL+""); 
    }
    and adding;
    Code:
    onClick="loadContent('#content', 'source_page.php');"
    to the JavaScript URL I have above, but I can't figure out how to write it into my JavaScript "spit-up" at the top of my post...

    Any ideas??
    Last edited by takuhii; 01-16-2009 at 03:12 PM. Reason: additional ideas

  2. #2
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I really don't get what you can't figure out how to do....
    but I can't figure out how to write it into my JavaScript "spit-up" at the top of my post...
    Please post a link to the page on your site that contains the problematic script so we can check it out.
    Please include your code so that we can take a look at it, we can't do much without it.
    Jeremy | jfein.net

  3. #3
    Join Date
    Aug 2006
    Location
    UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have this code here;
    Code:
    function thumbs_getItemHTML(item)
    {
        var url_m = item.link;
        return '<a href="' + url_m + '" title="' + item.title + '"><img src="' + item.url + '" width="152" height="80" border="0" alt="' + item.title + '" /></a>';
    };
    I need to find a way to get the code above to open the links into targetted DIVs, many AJAX examples work, but they require an onClick event to operate, I want to somehow integrate this code;

    Code:
    function loadContent(elementSelector, sourceUrl) { 
      $(""+elementSelector+"").load(""+sourceURL+""); 
    }
    
    onClick="loadContent('#content', 'source_page.php');"
    into the first code sample. So in essence adding an onLoad to the first code sample...

    I am afraid I cannot give you a URL as this is an internal project...

  4. #4
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    When I said code... I meant all your code.
    Jeremy | jfein.net

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
  •