<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Blog</title>
<link href="/Content/bootstrap.css" rel="stylesheet" />
<script src="/Scripts/jquery-1.9.1.js"></script>
<script src="/Scripts/bootstrap.js"></script>
</head>
<body>
<div style="margin-top: 55px;">
<style>
.list-group {
margin-bottom: 0px;
}
.Title {
cursor: pointer;
margin: 1px 0;
padding: 5px 0;
} h2 {
margin-top: 0px;
}
</style>
<div class="col-md-2">
<div href="#collapseOne"
data-toggle="collapse" aria-controls="collapseOne" class="text-center btn-primary Title">
Classification<div style="float: right; margin-right: 5px;">
<span class="glyphicon glyphicon-chevron-up"></span>
</div>
</div>
<ul id="collapseOne" class=" list-group panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<li class="list-group-item"><span class="badge">1</span> <a onclick="collapseOneFind()" href="#">测试类型</a></li>
</ul>
<br />
<div data-toggle="collapse" style="cursor: pointer;" href="#collapseTwo" aria-controls="collapseTwo" class="Title text-center btn-primary">
Tag<div style="float: right; margin-right: 5px;">
<span class="glyphicon glyphicon-chevron-up"></span>
</div>
</div>
<ul id="collapseTwo" class=" list-group panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
</ul>
<br />
<div data-toggle="collapse" style="cursor: pointer;" href="#collapseThree" aria-controls="collapseThree" class="text-center btn-primary Title">
Date<div style="float: right; margin-right: 5px;">
<span class="glyphicon glyphicon-chevron-up"></span>
</div>
</div>
<ul id="collapseThree" class=" list-group panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
</ul>
<br />
</div>
<div class="col-md-10"> </div> </div>
<script>  
function InitBlog(data) {
var strTemp = "";
for (var i = 0; i < data.length; i++) {
strTemp += ' <div class="btn-primary">';
strTemp += ' <h2>' + data[i].BlogTitle + '</h2>';
strTemp += ' </div>';
strTemp += '<div class="panel-body">';
strTemp += ' <div>';
strTemp += '<span style="color: #999;">' + data[i].CreateTime + '</span>';
if (data[i].Classifications!='') {
var ClassificationArr = data[i].Classifications.split(',');
for (var j = 0; j < ClassificationArr.length; j++) {
strTemp += '&nbsp;|<a style="color: #999; text-decoration: none;" href="#">' + ClassificationArr[0] + '</a>'
}
}
strTemp += ' </div>';
strTemp += '<div style="margin:5px 0">';
strTemp += data[i].Content;
strTemp += ' </div>';
strTemp += ' </div>';
strTemp += ' <div>';
if (data[i].Tag.indexOf(',') > 0) {
var TagArr = data[i].Tag.split(',');
for (var k = 0; k < TagArr.length; k++) {
strTemp += ' <button type="button" class="btn btn-default btn-xs">';
strTemp += ' <span class="glyphicon glyphicon-star" aria-hidden="true"></span>' + TagArr[k];
strTemp += ' </button> ';
}
}
strTemp += ' </div>';
}
return strTemp;
} function ClassificationFind(obj) {
$.ajax({
type: 'get', async: true, url: '/Blog/ClassificationFind', dataType: 'JSON', data: { Str: $(obj).text() }, cache: false, success: function (data) {
$("#Content").html(InitBlog(data));
}
});
}
function TagFind(obj) {
$.ajax({
type: 'get', async: true, url: '/Blog/TagFind', dataType: 'JSON', data: { Str: $(obj).text() }, cache: false, success: function (data) {
$("#Content").html(InitBlog(data));
}
});
} function DateFind(obj) {
$.ajax({
type: 'get', async: true, url: '/Blog/DateFind', dataType: 'JSON', data: { Str: $(obj).text() }, cache: false, success: function (data) {
$("#Content").html(InitBlog(data));
}
});
}
$(document).ready(function () {
//绑定折叠List 数据源
$.ajax({
type: 'get', async: true, url: '/Blog/GetClassification', cache: false, dataType: 'JSON', success: function (data) {
var strTemp = "";
for (var i = 0; i < data.length; i++) {
strTemp += ' <li class="list-group-item"> <span class="badge">' + data[i].Num + '</span> <a onclick="ClassificationFind(this)" href="#">' + data[i].ClassificationName + '</a></li>';
}
$("#collapseOne").html(strTemp);
}
});
$.ajax({
type: 'get', async: true, url: '/Blog/GetTagName', cache: false, dataType: 'JSON', success: function (data) {
var strTemp = "";
for (var i = 0; i < data.length; i++) {
strTemp += ' <li class="list-group-item"> <span class="badge">' + data[i].Num + '</span> <a onclick="TagFind(this)" href="#">' + data[i].TagName + '</a></li>';
}
$("#collapseTwo").html(strTemp);
}
}); $.ajax({
type: 'get', async: true, url: '/Blog/GetCreateDate', cache: false, dataType: 'JSON', success: function (data) {
var strTemp = "";
for (var i = 0; i < data.length; i++) {
strTemp += ' <li class="list-group-item"> <span class="badge">' + data[i].Num + '</span> <a onclick="DateFind(this)" href="#">' + data[i].CreateDate + '</a></li>';
}
$("#collapseThree").html(strTemp);
}
}); $.ajax({
type: 'get', async: true, url: '/Blog/GetBlog', cache: false, dataType: 'JSON', success: function (data) {
var r = $("#Content").html();
$("#Content").html(r + InitBlog(data));
}
});
});
$(".Title").click(function () {
var r = $(this).attr('class');
if (r.indexOf("collapsed") > 0) {
$(this).find("span").attr("class", "glyphicon glyphicon-chevron-up");
} else {
$(this).find("span").attr("class", "glyphicon glyphicon-chevron-down");
}
});
</script>
</body>
</html>

bootstrap collapse MVC .net漂亮的折叠List的更多相关文章

  1. bootstrap插件学习-bootstrap.collapse.js

    先看bootstrap.collapse.js的结构 var Collapse = function ( element, options ){} // 构造器 Collapse.prototype ...

  2. bootstrap collapse 无法收回

    $(function () { //修复collapse不能正常折叠的问题 $(".collapsed").click(function () { var itemHref = $ ...

  3. TextBoxFor控件的扩展---Bootstrap在mvc上的应用

    TextBoxFor控件的问题: 1:自带了样式,再用bootstrap样式会有冲突. 2:要加水印,js事件,限制输入长度比较麻烦. 因此需要对textboxfor控件进行扩展. 目标: 1:能使用 ...

  4. Bootstrap for MVC:Html.Bootstrap().TextBoxFor(model=>model.Name)

    在上篇博文中提到最近比较忙,也打过招呼Orchard系列文章更新速度可能会放缓,但还是会继续写下去,主要原因在最近想着开发一个新的东西(系统?组件?),等有一定成果时会跟大家分享一些相关的东西,今天介 ...

  5. Bootstrap Collapse使用

    参考 http://wrongwaycn.github.io/bootstrap/docs/javascript.html#collapse http://www.w3resource.com/twi ...

  6. Bootstrap 学习笔记11 按钮和折叠插件

     复选框: <div class="btn-group" data-toggle="buttons"> <label for="se ...

  7. Android分享一款漂亮的折叠书架菜单

    一个Android折叠书架菜单,效果极佳,给人的视觉感觉很好,便于使用. FoldingMenu

  8. 添加Bootstrap 到MVC项目中(vs2010)

    环境:Visual Studio 2010   ASP.NET MVC3 手动添加: 下载地址:http://twitter.github.com/bootstrap/ 一个js,两个css,两张图 ...

  9. bootstrap ace MVC

    <<html lang="en"><head> <meta charset="utf-8" /> <title& ...

随机推荐

  1. resharper 设置代码颜色

  2. github jekyll site不再使用Maruku由于Markdown翻译员,但kramdown

    今天写了一篇博客,之push至jekyll site on github在,发现总是错的,例如,下面的电子邮件消息: The page build completed successfully, bu ...

  3. 使用API创建AR 贷项通知单

    DECLARE --8000000063 l_dummy varchar2(240); l_customer_trx_id ra_customer_trx.customer_trx_id%type; ...

  4. C指针决心 ------ 指针表达式

    本文是自己学习所做笔记.欢迎转载.但请注明出处:http://blog.csdn.net/jesson20121020 所谓的指针表达式是指一个表达式.其结果是一个指针. 例1. int  a,b; ...

  5. POJ2112Optimal Milking(二分法+floyd最短+网络流量)

    职务地址:http://poj.org/problem?id=2112 近期忙着预习课本备考,没怎么刷题.(我是真的有在好好看书..)不敲题还是手痒痒.立即就邀请赛了,还是每晚睡觉前都拿来刷题吧.白天 ...

  6. [WebGL入门]四,渲染准备

    注意:文章翻译http://wgld.org/,原作者杉本雅広(doxas),文章中假设有我的额外说明,我会加上[lufy:].另外.鄙人webgl研究还不够深入,一些专业词语,假设翻译有误,欢迎大家 ...

  7. DOM笔记2

    <!-- 节点类型检查 if(someNode.nodeType==ElementNode){ alert("Node is an element"); } 或者 if(so ...

  8. [SignalR]配置路由

    原文:[SignalR]配置路由 注册路由,在代码如下(SignalR 1.*): 脚本修改如下: 但是其官方文档解释是: By default, the route URL which client ...

  9. 朝花夕拾-4-shell

    引言 shell,我们常常会用到,以其强大的功能,会帮助我们解决非常多棘手的问题.近期遇到一个问题,要跑非常多case,假设串行的执行,须要非常久.能不能让他们并行起来,但又不能全部case都并行执行 ...

  10. 数字IC设计-15-DPI(延续)

    简介 供SV,无论是构建测试激励,或模拟硬件的并行行为,DPI这是非常方便.上次我们介绍SV内通"import"导入和电话C性能. 在本节,通过一个简单的例子来说明C什么语言的函数 ...