0

I am trying to pass multiple parameters on flip using turn.js. The current option only made provision for the pageNumber ie.

Instead of

function addPage (page, book) {
    //Check if the page is not in the book
    if ( ! book. turn( 'hasPage' , page)) {
        // Create an element for this page
        var element = $ ( '<div />' ). html ( 'Loading…' );
        // Add the page
        book.turn( 'addPage' , element, page);
        // Get the data for this page
        $.ajax ({url : "app?method=get-page-content&page=" + page)
            .done( function (data) { element. html (data); });
    }
}

I want

function addPage (page, book) {
    // Check if the page is not in the book
    if ( ! book. turn( 'hasPage' , page)) {
        // Create an element for this page
        var element = $ ( '<div />' ). html ( 'Loading…' );
        // Add the page
        book.turn( 'addPage' , element, page, chapter);
        // Get the data for this page
        $.ajax ({url : "app?method=get-page-content&page="+ 
page+ "&currentChapter" + chapter)
            .done( function (data) { element. html (data); });
    }
}

So that I can determine the page in a chapter to serve.

Sample code will be greatly appreciated.

  • 1
    Currently, is chapter no. available at Front End? Also does your back end understands *currentChapter* query param? – abdul-wahab Jan 29 '18 at 19:58
  • I tried passing it from the front.. Using one of the examples here.. https://github.com/blasten/turn.js/tree/master/demos.. And yes the back end understands the currentChapter param – Olaolu Ajose Jan 29 '18 at 22:19
  • From front end, were they passing successfully (which you can confirm in network panel of chrome btw)? – abdul-wahab Jan 29 '18 at 22:21
  • The thing is.. If I use normal ajax call.. I can pass whatever I want to the server side.. But the libraries in question here only understands next page where pageNumber is the parameter supplied – Olaolu Ajose Jan 29 '18 at 22:23
  • Let's say chapter 1 has 10 pages. You want page 2 of chapter 2. Can't you use `addPage(12, book)`. When sending to back end, you can determine chapter and page no. by subtracting no. of pages from chapter one and so on. e.g. Page 12 must belong to chapter 2 because chapter 1 has 10 pages. – abdul-wahab Jan 29 '18 at 22:33
  • @abdul-wahab, good example but in this case it's not paginated at all.. And it will be difficult because each chapter is like a sub book.. With table of contents and their respective pages. So eg.. I have table of content for the entire book.. If you flip to page 4, it will still be in the table if content because that spans from say 1 to 9,but after that, I have sub books with sub chapters and can only transverse if I know where you are.. Parent or Sub book... You get? – Olaolu Ajose Jan 29 '18 at 22:38
  • internal class QueryHelper { public static PagingInfo GetPagingRowNumber(int pageIndex, int pageSize) { if (pageIndex < 1) pageIndex = 1; pageIndex = (pageIndex - 1) * pageSize; var page = pageIndex + pageSize; return new PagingInfo(pageIndex, page); } } sealed class PagingInfo { public PagingInfo(int rowStart, int rowEnd) { RowStart = rowStart; RowEnd = rowEnd; } Already doing this at the server side. – Olaolu Ajose Jan 29 '18 at 22:50
  • Say your biggest chapter has 900 pages (no chapter will exceed *1000* pages). With library, for chapter 1 page 10, use `1000 + 10 = 1010`. Will this work for you? – abdul-wahab Jan 29 '18 at 22:55
  • I should but the problem is this.. I am reading chapter 1 of book 1 which should switch to chapter 2 when the pages of chapter on is completed... I have no idea of the number of pages in chapter 1 because it varies from screen to screen.. I just take 7 lines and keep taking until it's exhausted. Then I go to chapter 2 and start taking another set of 7 lines.. If a reader decides to resume from last read.. If I know the chapter number I can jump there without having to count pages. Hope I'm making sense – Olaolu Ajose Jan 29 '18 at 23:03

0 Answers0