Bootstrap Multiselect 设置 option
$.ajax({
type: 'post',
url: "helper/ajax_search.php",
data: {models: decodeURIComponent(brands)},
dataType: 'json',
success: function(data) {
$('select.multiselect').empty();
$('select.multiselect').append(
$('<option></option>')
.text('alle')
.val('alle')
);
$.each(data, function(index, html) {
$('select.multiselect').append(
$('<option></option>')
.text(html.name)
.val(html.name)
);
});
$('.multiselect').multiselect('rebuild')
},
error: function(error) {
console.log("Error:");
console.log(error);
}
});
<extend name="Public/base" />
<block name='style'>
<style type="text/css">
.sctext{ width:700px; height: 300px;}
</style>
</block>
<block name="body">
<div class="main-title cf">
<h2>渠道授权页面</h2>
</div>
<br/>
<!-- 表单 -->
<form id="form" action="{:U('/Admin/System/User/userChannelAuth')}" method="post" class="form-horizontal">
<input id="user_id" name="user_id" type="hidden" value="{$_GET['id']}">
<input id="user_name" name="user_name" type="hidden" value="{$_GET['name']}">
<div class="form-item">
<label class="item-label">平台类型<span class="check-tips">(请勾选平台类型)</span></label>
<div>
<select id="platform_type" name="platform_type[]" multiple="multiple">
<volist name="platform_type" id="vo">
<in name="vo.type_id" value="$platform_type_id">
<option value="{$vo.type_id}" class="row-select" selected="selected">{$vo.type_name}</option>
<else/>
<option value="{$vo.type_id}" class="row-select" >{$vo.type_name}</option>
</in>
</volist>
</select>
</div>
</div>
<br/>
<div class="form-item">
<label class="item-label">渠道<span class="check-tips">(请勾选渠道)</span></label>
<div>
<select id="channel" name="channel[]" multiple="multiple">
<volist name="ChannelInfo_data" id="vo">
<in name="vo.id" value="$channel_id">
<option value="{$vo.id}" class="row-select" selected="selected">{$vo.cn_name}</option>
<else/>
<option value="{$vo.id}" class="row-select" >{$vo.cn_name}</option>
</in>
</volist>
</select>
</div>
</div>
<br/>
<div class="form-item">
<label class="item-label">授权用户:{$_GET["name"]}<span class="check-tips"></span></label>
</div>
<br/>
<div class="form-item">
<button type="submit" class="btns submit-btn ajax-post" target-form="form-horizontal">授 权</button>
</div>
</form>
</block>
<block name="script">
<script type="text/javascript" charset="utf-8">
//导航高亮
highlight_subnav('{:U('/Admin/System/User/index')}');
highlight_subnav('{:U('saveServer')}');
Think.setValue('lua','{:I('lua')}');
$('#platform_type').multiselect(
{
enableFiltering: true,
nonSelectedText:'请选择平台类型',
filterPlaceholder:'搜索',
nSelectedText:'项被选中',
includeSelectAllOption:true,
selectAllText:'全选/取消全选',
allSelectedText:'已选中所有平台类型',
maxHeight:300
});
$('#channel').multiselect(
{
enableFiltering: true,
nonSelectedText:'请选择渠道',
filterPlaceholder:'搜索',
nSelectedText:'项被选中',
includeSelectAllOption:true,
selectAllText:'全选/取消全选',
allSelectedText:'已选中所有渠道',
maxHeight:300
});
$("#platform_type").bind("click",function(){
$("#channel option[value]").remove();
});
$("#platform_type").bind("change",function(){
var platform_type_ids=$("#platform_type").val();//获取所有的平台类型
if(platform_type_ids!=null){
var ulr='{:U('/Admin/System/User/getChannel')}';
$.ajax({
type:"GET",
url:ulr,
data:{ids:platform_type_ids},
dataType:"json",
success:function(data){
$("#channel option[value]").remove();
$(data).each(function(k,v){
$('#channel').append(
//selected="selected"
$('<option ></option>').text(v["cn_name"]).val(v["id"])
);
});
$('#channel').multiselect('rebuild');
$("#channel").multiselect( 'refresh' );
}
});
}else{
$('#channel').multiselect('destroy');
$('#channel').empty();
$('#channel').multiselect({
enableCaseInsensitiveFiltering : true,
nonSelectedText:'请选择渠道',
maxHeight:300
});
}
});
</script>
</block>
Bootstrap Multiselect 设置 option的更多相关文章
- web 前端常用组件【03】Bootstrap Multiselect
实际的项目网站中或多或少的或用到多选框,我选用的一款是 Bootstrap Multiselect. 官方文档:http://www.kuitao8.com/demo/20140224/1/boots ...
- JS组件系列——两种bootstrap multiselect组件大比拼
前言:今天继续来看看bootstrap的另一个组件:multiselect.记得在项目开始之前,博主项目组几个同事就使用哪些js组件展开过讨论,其中就说到了select组件,由于项目的整体风格使用的b ...
- bootstrap multiselect两大组件
组件说明以及API 1.第一个组件——multiple-select.这个组件风格简单.文档全.功能强大.但是觉得它选中的效果不太好.关于它的效果展示,我们放在后面. 2.第二个组件——bootstr ...
- Bootstrap Multiselect插件使用步骤以及常见参数配置介绍
Multiselect是基于jQuery插件的,它可以以下拉列表的形式为用户提供选择内容,能进行单选或者多选.它应用的主要步骤如下: 一,引入需要的相关js和css文件 既然是Bootstrap插件, ...
- Bootstrap Multiselect
Getting Started Link the Required Files First, the jQuery library needs to be included. Then Twitter ...
- 使用BootStrap框架设置全局CSS样式
一.排版 标题 HTML 中的所有标题标签,<h1> 到 <h6> 均可使用.另外,还提供了 .h1 到 .h6 类,为的是给内联(inline)属性的文本赋予标题的样式. & ...
- easyui-combobox 设置option内容不换行
使用easyui 1.4.4 1 2 3 4 5 6 7 8 <select id="hotalid" class="easyui-combobox" d ...
- Django实战(5):引入bootstrap,设置静态资源
之前生成了Product类的scaffold,但是如同rails的开发者David所讲的那样,scaffold几乎没什么用.所以按照<Agile Web Development with Rai ...
- js 动态设置 option 的selected 选项
思路:通过for循环判断每个选项,一旦满足条件则设置其selected属性为true即可,关键代码: var obj = document.getElementById(select_id); for ...
随机推荐
- mysql 创建函数或者存储过程,定义变量报错
报错的原因是因为在过程或者函数中存在分隔符 分号(:),而mysql中默认分隔符也是 :,这就导致存储过程分开了 在存储过程外面包一层 delimiter // code //就行了
- recess----2.Controller里面取用request信息
事实上,第一个APP里面除了没有model,其它的都有用过了,但是需要单独拎出来看看清楚. Recess框架里面的controller就是一个典型的MVC框架的controller,它负责处理从浏览器 ...
- 进程上下文切换 – 残酷的性能杀手(上)(转载cppthinker.com)
对于服务器的优化,很多人都有自己的经验和见解,但就我观察,有两点常常会被人忽视 – 上下文切换 和 Cache Line同步 问题,人们往往都会习惯性地把视线集中在尽力减少内存拷贝,减少IO次数这样的 ...
- Building Vim from source(转)
Compiling Vim from source is actually not that difficult. Here's what you should do: First, install ...
- 【Python】学习笔记十:字典
字典是Python中唯一的映射类型(哈希表) 字典的对象时可变的,但字典的键值必须是用不可变对象,并且一个字典中可以使用不同类型的键值 1.定义字典 dict={key1:value1,key2:va ...
- 【VBA编程】09.使用Excle集合对象
使用Workbooks工作簿集合.工作簿对象.工作表集合.工作表对象,并且观察使用Add方法前后工作簿与工作表数目的变化 [代码区域] Sub 测试集合工作簿() Dim wbs As Workboo ...
- FIS3项目构建
概述 FIS3采取了类似CSS语法一样的配置风格,易于理解与上手.FIS3 是面向前端的工程构建工具.解决前端工程中性能优化.资源加载(异步.同步.按需.预加载.依赖管理.合并.内嵌).模块化开发.自 ...
- Vue学习小结
ES6 let完全可以取代var const声明一个只读的常量 箭头函数:可以绑定this对象,大大减少了显式绑定this对象的写法(call.apply.bind) 函数绑定(function bi ...
- 使用swagger实现在线api文档自动生成 在线测试api接口
使用vs nuget包管理工具搜索Swashbuckle 然后安装便可 注释依赖于vs生成的xml注释文件
- 跨浏览器的CORS
function createCORSRequest(method, url){ var xhr = new XMLHttpRequest(); if("withCredentials&qu ...