<!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. POJ 1984 Navigation Nightmare (数据结构-并检查集合)

    Navigation Nightmare Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 4072   Accepted: 1 ...

  2. Visual Studio中开发

    如何在Visual Studio中开发自己的代码生成器插件    Visual Studio是美国微软公司开发的一个基本完整的开发工具集,它包括了整个软件生命周期中所需要的大部分工具,如UML工具.代 ...

  3. 具体的了解“&gt;/dev/null 2&gt;&amp;1”

    Linux系统中不管是crontab里面.还是平时使用的命令.常常会碰到">/dev/null 2>&1".比方说:在Crontab Job里面,假设不想发送邮 ...

  4. Redis是新兴的通用存储系统-为何Redis要比Memcached好用

    GitHub版本地址: https://github.com/cncounter/translation/blob/master/tiemao_2014/Redis_beats_Memcached/R ...

  5. 飞信免费邮件api,飞信界面

    大家都知道飞信是能够免费发送短信的,可是飞信又没有官方的接口,所以无法借用移动的官方接口实现短信的免费发送,可是还是有一些破解的接口能够使用的. GET方法: 提交格式 http://66.zzuob ...

  6. POJ 2418 Hardwood Species(STL在map应用)

    职务地址:id=2418">POJ 2418 通过这个题查了大量资料..知道了非常多曾经不知道的东西. . .. 在代码中凝视说明吧. 代码例如以下: #include <ios ...

  7. RH253读书笔记(2)-Lab 2 System Resource Access Controls

    Lab 2 System Resource Access Controls Goal: To become familiar with system resource access controls. ...

  8. java major version(转)

    在jar包中,用winrar解压一个类文件,然后在命令行下面输入 javap -verbose classname 会输出一些信息,大致如下: Compiled from "HtmlCraw ...

  9. ORACLE 创建表空间、用户、授权

    1.创建表空间 create tablespace TEST  logging datafile 'e:\app\administrator\oradata\orcl\TEST.dbf' size 1 ...

  10. Java多线程中wait, notify and notifyAll的使用

    本文为翻译文章,原文地址:http://www.journaldev.com/1037/java-thread-wait-notify-and-notifyall-example 在Java的Obje ...