Files
vczero.github.io/iblog/js/article.js
T
2014-06-24 17:43:39 +08:00

33 lines
646 B
JavaScript

/*
tpl渲染博客内容
*/
$(function(){
seajs.use('./blog/blogs_details.js', function(exports){
var url = window.location.search;
var id = url.split('id=')[1];
var blog = exports.blogs[id];
var bs = [];
bs.push(blog);
createBlog(bs, 100);
});
function createBlog(blogs, n){
var blogs = blogs;
var num = n > blogs.length ? blogs.length:n;
var element = $('#showblog');
var tpl = $('#tpl_blog').html();
var myBlogs = [];
for(var i = 0; i < num; i++){
myBlogs.push(blogs[i]);
}
var data = {
list: myBlogs
}
var html = _.template(tpl, data);
element.html(html);
}
});