<!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. 如何在Dreamweaver中使用zen coding

    在我发表上一篇<Zen Coding: 一种快速编写HTML/CSS代码的方法>之后,有网友表示不知道怎么在Dreamweaver上使用zen coding插件.OK,今天我就写一篇详细的 ...

  2. 【Android进阶】SlidingMenu实现侧滑栏效果的实现

    public class MainActivity extends Activity { @Override protected void onCreate(final Bundle savedIns ...

  3. LeetCode :: Convert Sorted Array (link list) to Binary Search Tree [tree]

    1.Given an array where elements are sorted in ascending order, convert it to a height balanced BST. ...

  4. PHP訪问MySql数据库 0基础篇

    在站点后台,常常要与数据库打交道.本文介绍怎样使用XAMPP来管理MySql数据库及怎样用PHP来訪问MySql数据库. 一.使用XAMPP来管理MySql数据库 首先使用XAMPP打开MySql的管 ...

  5. C# 使用WinRar命令压缩和解压缩

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  6. IndexReader已解决的问题

    设计和实时搜索的发展,IndexReader饮酒数成为0当调用doClose,和SegmentReader再有一个addCoreClosedListener控制的方法SegmentCoreReader ...

  7. 【转】Android 避免APP启动闪黑屏(Theme和Style)

    前几天Boss就反应说,机器每次启动程序都会闪一下黑屏,这个客户不接受.没办法,只能想想怎么解决,最后找到了下面的方法.闪黑屏的原因主要是我们启动Activity的时候,需要跑完onCreate和on ...

  8. bsh for android : 北京

    beanshell : bjtime.bsh source("/sdcard/com.googlecode.bshforandroid/extras/bsh/android.bsh" ...

  9. Mesos-error

    1,configure: error: cannot find libcurl 解决 yum install  curl-devel 版权声明:本文博客原创文章,博客,未经同意,不得转载.

  10. 用Ghostscript API将PDF格式转换为图像格式(C#)

    原文:用Ghostscript API将PDF格式转换为图像格式(C#) 由于项目需要在.net下将pdf转换为普通图像格式,在网上搜了好久终于找到一个解决方案,于是采用拿来主义直接用.来源见代码中注 ...