how to add page at the front
I use $('selector').turn('addPage', element, 1), but it not work.
There are errors as below:
-
When there is no page in the magazine, the new page don't appear in the magazine after invoking turn('addPage', element, 1) ;
-
When there is only one page in the magazine, an error of " throw new Error ('"'+page+'" is not a page for range');" occurs after invoking turn('addPage', element, 1);
-
When there is more pages in the magazine, the old end page lost after invoking turn('addPage', element, 1);
Anybody can help? thanks.
@zhangzhzh I saw one problem in the 3rd release when removing a page, but not when adding. The problem of range was solved in the 4th version. I will update the current release to solve the problem. Do you have a code snippet?
I'm having the same problem using version 4.1.0 ... Seems that you have to refresh the number of pages after adding a new one at the front, or the last page will be unreachable (out of range).
$('#magazine')
.turn('addPage', $('<div />'), 1)
.turn('pages', $('#magazine').turn('pages')+1);
@blasten I was wrong, if you do as I descripted above, you'll get something broken when trying to flip the page. The error is :
Uncaught TypeError: Cannot read property 'f' of null turn.js:1913
@bongofury Yes, this is because the way it was designed, turn.js thinks that you are adding a page to a section that isn't in memory (dynamic pages) instead of a new page. This problem has been fixed in the upcoming update. In other words, the current version only allows to add pages at the end:
$('#magazine')
.turn('addPage', $('<div />'), $('#magazine').turn('pages')+1);
So how is this fixed ? Any idea ? Or is this library deprecated?