views:

135

answers:

1

So i've been doing quite a simple ajax call to grab my photo albums with some pagination. My rounded corners worked before i added the ajax calls. The selectors are correct as well. I'm doing the 'cornering' on the callback for my .load and yet i can't get it to work :s Any ideas:

//Display Loading Image
function Display_Load()
{
    $("#loading").fadeIn(900,0);
    $("#loading").html("<img src='/images/loading.gif' />");
}
//Hide Loading Image
function Hide_Load()
{
    $("#loading").fadeOut('slow');      
};

function display_corners()
 {
            $('.album_shell li .album_photo_shell').corner("round 3px").parent().css('padding', '6px').corner("round 13px");
            $('.album_photo').corner("round 5px").parent().css('padding', '4px').corner("round 6px");
};  

//Default Starting Page Results

$("#pagination_nav li:first").css({'color' : '#FF0084'}).css({'border' : 'none'});

Display_Load();
var album_id = $(document).getUrlParam("album_id"); 
$("#content").load("pagination_data.php?page=1&album_id=" + album_id, Hide_Load(),display_corners());

//Pagination Click
$("#pagination_nav li").click(function(){

    Display_Load();

    //CSS Styles
    $("#pagination_nav li")
    .css({'border' : 'solid #dddddd 1px'})
    .css({'color' : '#0063DC'});

    $(this)
    .css({'color' : '#FF0084'})
    .css({'border' : 'none'});

    //Loading Data
    var pageNum = this.id;

    $("#content").load("pagination_data.php?page=" + pageNum + "&album_id=" + album_id, Hide_Load(),display_corners());
});
A: 

You are calling the actual functions vs. just passing references. Additionally, you are passing two separate functions vs. just one that the load method accepts. You should change it to something like this:

$("#content").load("pagination_data.php?page=1&album_id=" + album_id, function(){
    Hide_Load();
    display_corners();
});

I would abstract it like this:

function get_album( album_id, page_number ){
   if(!page_number) page_number = 1;
   Display_Load();
   $("#content").load("pagination_data.php?page=1&album_id=" + album_id, function(){
      Hide_Load();
      display_corners();
   });
};
Doug Neiner
Well dude, i've learnt something today ;) Cheers for your help worked like a charm.
Jamie Hutber
Happy to help! Welcome to StackOverflow. Hope to see you around!
Doug Neiner