I have a json with a book pages, and each book is different I would like to create it so pages are created based on the book size.
Using the template I can do this, but to add static pages when I do not know the length of the book is a little silly.
I have this code, which shows part of the JSON and the code I am trying to add to the existing page. But I get no errors, and I do not know where the new HTML is being appended.
precode
"page18": {
"audio": "link to page audio",
"text": "Her room was bright again and Chloe was happy about that. She turned to the lamp and looking back was a big smilely face, with a small noise and two eyes. 'Hello' said the lamp shade. 'My name is Percy, Percy Shade' he continued and finished with a warm smile.",
"images": {
"pageImage": "page8_image.jpg"
}
},
Code: Select all
"page19": {
"audio": "link to page audio",
"text": "Her room was bright again and Chloe was happy about that. She turned to the lamp and looking back was a big smilely face, with a small noise and two eyes. 'Hello' said the lamp shade. 'My name is Percy, Percy Shade' he continued and finished with a warm smile.",
"images": {
"pageImage": "page8_image.jpg"
}
},
"page20": {
"audio": "link to page audio",
"text": "Her room was bright again and Chloe was happy about that. She turned to the lamp and looking back was a big smilely face, with a small noise and two eyes. 'Hello' said the lamp shade. 'My name is Percy, Percy Shade' he continued and finished with a warm smile.",
"images": {
"pageImage": "page8_image.jpg"
}
}
};
//Get page Count
var pages;
var PageCount = 0;
for (pages in book) {
PageCount++;
}
console.log(PageCount);
//Load pages into variable
var newPages = '';
for(p=0; p == PageCount; p++) {
newPages += '<div data-role="page" style="min-height: 768px;" dsid="page'+p+'" id="page'+p+'" class="type-interior ui-page ui-page-theme-a" data-theme="a" data-url="page'+p+'" tabindex="0">Test Text<>';
}
//console.log(newPages);
//Post variables to screen
$(newPages).appendTo('div[data-role="page"]');
/code/pre
Do you have any ideas on this ?