我需要动态构建一本书。我使用的是turnjs。看看这个小提琴:JSFIDDLE LINK
下面是添加页面的函数:
function addContent() {
var element = '<p>SomeContent</p><a href="#">Go To Page 1</a>';
var pageCount = $('#flipbook').turn('pages') * 1;
$('#flipbook').turn('addPage', element, pageCount+1)
.turn('pages', $('#flipbook').turn('pages'));
}第一个问题是页面是在最后添加的,首先我需要控制这一点,以便在我想要的地方添加页面。
第二个问题是添加的页面没有得到书本效果!好像这不是书的那一页。我该如何解决这个问题呢?
任何帮助都将不胜感激。
发布于 2014-02-28 00:22:52
如果你只是使用了设置你想要包含的页面总数的函数,你的代码可能会正常工作,否则库将从最后删除所有额外的页面。换句话说,这个版本的代码将完美地工作。
function addContent() {
var pageCount = $('#flipbook').turn('pages')+1 ;
var possitionOfAddition = 2 ;// this is an example, place the position you want to add the new content , use the var pageCount in case you want to add into last.
element = $('<div>This is test</div>');
alert('just befor the addition');
$('#flipbook').turn('addPage', element,possitionOfAddition);
alert('just after the addition');
$('#flipbook').turn('pages', pageCount); // Sets the total # of pages
}https://stackoverflow.com/questions/21656637
复制相似问题