我正在 asp.net 中制作一个 Web 应用程序。我需要翻页效果,所以我使用了 turn.js(参考:http ://www.turnjs.com/ )。现在我需要在服务器端处理一些数据,即代码隐藏并将其发送到客户端。我从上面的网站(来自:https ://github.com/blasten/turn.js )下载了这个项目。但问题是我无法弄清楚如何将数据从代码隐藏发送到实际加载动态页面的 .aspx 页面中的 JavaScript。
function addPage(page, book) {
// First check if the page is already in the book
if (!book.turn('hasPage', page)) {
// Create an element for this page
var element = $('<div />', {'class': 'page '+((page%2==0) ? 'odd' : 'even'), 'id': 'page-'+page}).html('<i class="loader"></i>');
// If not then add the page
book.turn('addPage', element, page);
// Let's assum that the data is comming from the server and the request takes 1s.
setTimeout(function(){
element.html('<div class="data">Data for page '+page+'</div>');
}, 1000);
}
}
这是添加动态页面的 JavaScript 函数。如何在行中添加页面内容element.html('<div class="data">Data for page '+page+'</div>');
。