Skip to content

component triggered right away then never again #10

Closed
@packytagliaferro

Description

@packytagliaferro

I load in a bunch of content via php (about 45 objects) and when the page loads it will load the first 6 as i wanted, but then before I even scroll it will load another 6 (which it should do on scroll). Then if I scroll to the bottom it never loads anymore content.

Does having a footer on the page effect any of this?

<div class="wrap-content" id="home">

    <div class="container">
        <h1>Tips</h1>
        <h2>Inspiration comes from everywhere.</h2>

        <ul id="tip-list" class="item-list">

            <li v-for="item in list">
                <p class="tag-name">{{ item.tags[0].tag_name }}</p>
                <div class="actions-container"></div>
                <p class="tip">"{{ item.content_stringoption1 }}"</p>
            </li>

            <infinite-loading :on-infinite="onInfinite" :distance="distance"  spinner="waveDots" ></infinite-loading>

        </ul>

    </div>

</div>


<script type="text/javascript">

    var data = <?php echo json_encode( $content ) ?>;

    $(document).ready(function() 
    {
        new Vue({
            el: '.item-list',
            data: {
                distance: 10,
                list: []
            },
            ready: function () 
            {
                for (var i = 0; i < 6; i++) 
                {
                    this.list.push( data[i] );
                }
            },
            methods: {
                onInfinite: function () 
                {
                    setTimeout(function () 
                    {
                        var temp = [];
                        for (var i = this.list.length; i <= this.list.length + 5; i++) {
                            temp.push( data[i] );
                        }

                        this.list = this.list.concat(temp);
                        this.$broadcast('$InfiniteLoading:loaded');
                    }.bind(this), 1000);
                }
            }
        })

    });

</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions