Welcome Guest, Not a member yet? Register   Sign In
[Solved...but messy] clickable thumbnails to open jQuery gallery with AJAX
#2

[eluser]pickupman[/eluser]
You are definitely on the right track. A few quick notes.

1.) You url doesn't look correct base_url() / test.php What is the name of your controller you are using in CI. Example say it is gallery.
Code:
<?php echo site_url('gallery');?> //Will create link properly

2.) Using .load() and passing a parameter is going to run a GET request which CI doesn't run natively. You could use:
Code:
function blubb(portid)
{
   $("#myGallery").load("<?php echo site_url('gallery'); ?> / + portid"); //Loads http://yoursite/(index.php/)gallery/portid
}

3.) Anytime you will be loading / changing items on the page you will need to use the [url="http://api.jquery.com/live/"]live()[/url] function. This will reattach the click handler for new loaded DOM elements. .click() only attaches itself to elements when the page is loaded.

4.) Add a class your a(nchor) tags for your thumbnails, and remove the onclick event from them. Instead use:
Code:
echo '<li><  a class="thumb_link" title="' . $tisch->id . '" href="#'.$tisch->name.'"><img> src="'.base_url().'img/tische/'.$tisch->thumb.'.jpg" alt="'.$tisch->name.'" title="'.$tisch->name.'" /></a></li>'; echo "\n";

//Javascript
$(".thumb_link").live('click', function(){
  blubb($(this).attr("title")); //Get title attribute from link and pass to blubb() function
});


Messages In This Thread
[Solved...but messy] clickable thumbnails to open jQuery gallery with AJAX - by El Forum - 05-04-2011, 07:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB