Search code examples
jqueryajaxsticky

Ajax content in stick titles


I have issue with ajax content in https://github.com/desandro/sticky-titles i did re initialise it by the .load function still new content doent get the data attribute correctly

    stickies=jQuery(".followMeBar");
            console.log(stickies);
    stickies.each(function(){
    console.log('in load each');
        var thisSticky = jQuery(this).wrap('<div class="followWrap" />');
            thisSticky.parent().height(thisSticky.outerHeight());

        jQuery.data(thisSticky[0], 'pos', thisSticky.offset().top);

    });

Solution

  • Got solution to it by creating a seperated div for fixed head

        /*Code for fixed date row*/
                    var flipVal;// offset value of current date on top
                    var currentIndex=0;//index  value of current date on top
                    var topOffsetValue=51;//(constant) offset value of fixed date from window top
                    var  stickDateToTop = function(){
                        var elements=jQuery(".order-date");//get obj of all date row elements 
                                elements.each(function(index, value){
                                    var thisObj = jQuery(value);
                                    var divOffset = thisObj.offset().top;
                                    currentElemnt=jQuery(elements[currentIndex]);
                                    /* to Handle to date on scroll up */
                                    if(currentElemnt.offset().top>flipVal){
                                        var backObj=jQuery(elements[currentIndex-1]);
                                        jQuery('#topDate').html(backObj.html());
                                    }
                                    /* to Handle to date on scroll down */
                                    if(divOffset <topOffsetValue && divOffset>0){
                                        currentIndex=index;
                                        flipVal=divOffset;
                                        jQuery('#topDate').html(thisObj.html());
                                    }
                                });
                    }
                    /*End of Code for fixed date row*/
    <div id="topDate" class="order-date-main fixed">
                <!--fixed date here -->
            </div>