script.blade.php 1.03 KB
<script>
$(document).ready(function() {
    console.log('load script...');
    var block_show = false;

    function scrollMore() {
        var $target = $('#showmore-triger');

        if (block_show) {
            return false;
        }

        console.log('function ScrollMore');

        if (true) {
            var page = $target.attr('data-page');
            page++;
            block_show = true;

            $.ajax({
                type: "GET",
                url: "{{ url()->full()}}",
                data: "page=" + page,
                dataType: 'html',
                success: function (data) {
                    $('#showmore-list').append(data);
                    block_show = false;
                }
            });

            $target.attr('data-page', page);
            if (page == $target.attr('data-max')) {
                $target.remove();
            }
        }
    }

    $(document).on('click', '#showmore-triger', function () {
        console.log('click paginate...');
        scrollMore();
    });
});
</script>