Items are called from a database which are used to populate a gallery. The modal and masonry scripts work on page load, but when i use the menu script to replace the content of my gallery, scripts stop working.
I struggled with the columns code until discovering clone(true, true)); so i imagine its a similar issue.. but i cant figure this one out. The closest I got was separating the js files and re-linking (yes) them in the php files... :| haha.. this "worked" but created other inconsistencies (increased the increments of the next button by 1 each time a menu item was clicked)
This is my menu code:
        function showHome(){
        $(".deck").empty();
        $.ajax({url: "databaseAll.php", success: function(result){
            $(".deck").html(result);
        }});
        createColumns();
        $("body").animate({scrollTop : $("#header").offset().top}, 1000);
    }
    $(".hm").click(showHome);
    $(".menuLogo").click(showHome);
This is the column code (works on page load and resize)
function createColumns () {
    $(".columns").empty();
    var noColumns = Math.floor($("#gallery").width() / 210);
    if (noColumns<1) {noColumns=1;}
    for (i = 0; i < noColumns; i++) {
        var $column = $("<div>", {"class": "column"});
        $(".columns").append($column);
    }    
    var deckClone = $(".deck").clone(true, true);
    var noCards = $(".deck").children().length;
    var cards = $(".card");
    var cardPosition = 0;
    for (i=0;  i <= noCards; i++) {
        if(cardPosition > noColumns - 1 ){cardPosition = 0;}
        $(".column").eq(cardPosition).append(cards.eq(i));
        cardPosition++;
    }
$(".deck").replaceWith(deckClone.clone(true, true));
cardPosition = 0;
}
createColumns();
function debounce(func, wait, immediate) {...}
$(window).resize(debounce(createColumns,400));
This is to show the modal (works on page load and resize)
function showModal() {
    $("body").css("overflow-y", "hidden");
    $(".small").removeClass("smallHover");
    $("#modal").fadeIn(200);
    var altLong = $(this).attr("alt");
    var altSplit = altLong.split("#");
    $(".picTitle").text(altSplit[0]);                                   
    $(".picStory").text(altSplit[2]);
    var srclong = $(this).attr("src");
    var srcshort = srclong.split("_");
    var srcextension = srclong.split(".");
    $(".big").attr("src", srcshort[0]+'.'+srcextension[1]); 
}
$(".small").click(showModal);
Please help me! Been struggling for weeks on this.. To view the code in action: jarrettonions.co.za
This newb thanks you!!
