Find out that report has next pages

by NesterOne

HTML

<script src="http://build-master.jaspersoft.com:7780/jrs-pro-feature-nojavascript/client/visualize.js?_opt=true"></script>
<div id="container"></div>

JavaScript

visualize({
    auth: {
        name: "superuser",
        password: "superuser"
    }
}, function (v) {
    var report = v.report({ 
        resource: "/public/viz/Slow_Report/easy_200000", 
        events: {
            changeTotalPages: function(totalPages) {
                console.log("Total Pages:" + totalPages);
                // TODO: init pagination if it was not yet initialized
            }
        },
        success: function() {
            console.log("Page 1 is ready");
            
            report.container("#container").render()
                .fail(function(er) { alert(er); })    
                .done(function() {
                    if (!report.data().totalPages) {
                        report.export({ outputFormat: "html", pages: 2 })
                            .fail(function(er) { alert(er); })
                            .done(function() {
                                console.log("Page 2 is ready");

                                // TODO: init pagination if it was not yet initialized                            
                            });
                    }
                });
        },
        error: function(er) {
            alert(er);
        }
    });
});