PDA

View Full Version : jQuery JS Load in a Div Help



takuhii
01-16-2009, 03:46 PM
Hi,
I really need some help with this, I have a function that automatically generates a bulleted list of thumbnails;


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;

function loadContent(elementSelector, sourceUrl) {
$(""+elementSelector+"").load("http://yoursite.com/"+sourceURL+"");
}

and adding;

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??

Nile
01-16-2009, 09:59 PM
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.

takuhii
01-17-2009, 05:54 AM
I have this code here;

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;


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...

Nile
01-17-2009, 11:38 PM
When I said code... I meant all your code.