Nolia 给CC添加过滤器
思路:
1.使用jqurey-tagput ,做得不好看,领导不满意
2.使用bootstrap select2这个控件,
思路:
1.添加css和js的文件
2.添加标签的时候,根据id拼接标签,addSearBox的时候会添加初始化数据,根据不同的id进行初始化;这样添加的时候界面就变化了
3.后来刷新界面以后,页面发生变化,做了这样的操作,添加这样的代码

4.添加选择,和非选择的事件,这点还是很麻烦的;用了一个小算法
var id = target.attr('id');//CC=basic-14
if(id=="basic-14"){
$.ajax({
type:"get",
url:"http://localhost:8080/4booking/js/CCtest.json",
dataType:"json",
asynchronous:true,
contentType:"application/json",
success:function(data){
//alert("success");
var data1 = $(data.items);
var result = [];
$.each(data1,function(infoIndex,info){
if(info.business == "" && info.owner == "")
{
result.push({id: info.id, text: info.name});
}
else{
result.push({id: info.id, text: info.name+ ":"+ info.owner + "," + info.business});
}
})
// oneReq = result;
$("#basic-14").select2({
data: result,
placeholder:'Please Select',//默认文字提示
// language: "en",//汉化
allowClear: true//允许清空
})
var temp =[];//删除保存上一次
var tmp1 =[];//保存上一次
$("#basic-14").on("select2:select",function(e){
//1.获取数据
//2.添加标签
// e 的话就是一个对象 然后需要什么就 “e.参数” 形式 进行获取
//alert("我选择了");
var ids= $("#basic-14").select2('val');
var arrIds = ids.toString().split(',');
temp = arrIds;
//tmp1 = arrIds;
// alert(tmp1);
//alert(ids);//添加的时候没有添加对,因为数组是动态的
if(tmp1==null){
tmp1 = [];
}
if(tmp1.length==0){
//alert("我的 00");
addTreeSubmitInput("basic-14", ids[0]);
}else{
//alert("1111111");
for(var i=0;i<ids.length;i++){//每一个值
var num = 0;
for(var j=0;j<tmp1.length;j++){
if(ids[i]!=tmp1[j]){
num++;
}
}
if(num==tmp1.length){
//alert("addddd");
addTreeSubmitInput("basic-14", ids[i]);
break;
}
}
}
tmp1 = ids;
console.log(e);
})
$("#basic-14").on("select2:unselect",function(result){
//1.获取数据
//2.添加标签
//$('#' + 'qqq' + '_treeSubmitInput').remove();
var ids= $("#basic-14").select2('val');
tmp1 = ids;
//alert(tmp1);
//alert(ids);
//alert(temp);
if(ids==null){
//alert("xxxxx");
$('#' + temp[0] + '_treeSubmitInput').remove();
}else{
for(var i=0;i<temp.length;i++){//每一个值
var num = 0;
for(var j=0;j<ids.length;j++){
if(temp[i]!=ids[j]){
num++;
}
//alert(num);
}
//alert("xxx");
if(num==ids.length){
//alert(temp[i]);
if(ids!=null){
$('#' + temp[i] + '_treeSubmitInput').remove();
}
console.log(temp[i]);
break;
}
}
}
temp = ids;
})
//alert($(oneReq).size());
},
error:function(data){
alert("lose");
}
});
Nolia 给CC添加过滤器的更多相关文章
- Hibernate之HQL添加过滤器查询的用法
HQL查询过程中支持添加过滤器.使用步骤是这样的: 首先在要查询的实体对象的映射中使用<filter-def>标签配置过滤器,并在相对应的<class>标签中添加对应的< ...
- 【C#】WebApi 添加过滤器,实现对请求参数和响应内容的日志记录
filter的介绍 filter在Web API中经常会用到,主要用于记录日志,安全验证,全局错误处理等:Web API提供两种过滤器的基本类型:actionfilterattribute,excep ...
- mvc 添加过滤器并添加session缓存判断
功能实现: 登录时添加session缓存.判断是否登录过期. 1.判断是否需要登录判断 public static AdminLoginUser GetAdminLoginUser(){#region ...
- jsp中添加过滤器,实现校验用户身份
我现在需要实现一个功能,就是用户登录前不允许访问系统,我使用的是jsp的过滤器来实现的. 先把filter过滤器的代码粘出来: package com.day8.filter; import java ...
- vue 添加过滤器-以格式化日期为例
vue的filter和angular的pipe管道类似,是过滤器 官网:https://cn.vuejs.org/v2/guide/filters.html 添加格式化日期的全局过滤器 在main.j ...
- AngularJS 表达式中添加过滤器实例
过滤器可以通过一个管道字符(|)和一个过滤器添加到表达式中 历练实例: <!DOCTYPE html><html><head><meta http-equiv ...
- Spring Cloud - Zuul添加过滤器
Zuul作为网关的其中一个重要功能,就是实现请求的鉴权.而这个动作我们往往是通过Zuul提供的过滤器来实现的. 一.过滤器方法的作用 想要使用Zuul实现过滤功能,我们需要自定义一个类继承ZuulFi ...
- Vue-easyui中如何给ComboGrid添加过滤器
1,给ComboGrid绑定监听事件,将事件对象传入.文档:http://www.jeasyui.net/vue/653.html @filterChange="example($event ...
- .NetCore 在不同位置添加过滤器
前言 以ParaModelValidateAttribute(参数校验)和ErrorCatch(错误捕捉)为例. 在方法上添加(局部) 这种方式比较灵活 [ParaModelValidate] [Er ...
随机推荐
- 【异常】Application failed to start due to an exception org.springframework.beans.factory.BeanCurrentlyInCreationException
一. 异常信息: 2018-05-17 18:03:22.224 -DEBUG [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter ...
- 卸载 PrestaShop 1.7
PrestaShop 的卸载非常简单: 在你的 Web 服务器上删除所有 PrestaShop 的文件和目录.你可以使用 FTP 客户端,你也可以使用 SSH 工具. 使用数据库工具删除数据库中所有以 ...
- 2-24-源码编译搭建LAMP环境-作业 ( By 小甘丶 )
安装上课的内容要求: 实验环境: VMware Virtual Machine : System Version: CentOS6.8 ( Gan35 ) IP Address : 192.168.3 ...
- iOS UI-标签控制器(UITabBarController)
#import "AppDelegate.h" #import "FirstViewController.h" #import "SecondView ...
- conv1d UpSampling1D aotoencoder 自编码代码摘录
https://www.quora.com/How-do-I-implement-a-1D-Convolutional-autoencoder-in-Keras-for-numerical-datas ...
- Java-Runtime 类
https://www.cnblogs.com/slyfox/p/7272048.html Java-Runtime 类 Runtime 类代表着Java程序的运行时环境,每个Java程序都有一个Ru ...
- SQL触发器实例(上)
--1.) 创建测试用的表(testTable) if exists (select * from sysobjects where name='testTable') drop table test ...
- kill prefix extra,endo out 1
1●extra 超过外面的, 以外的,外面 的 2●endo 内部
- 0001——初涉MySQL
MySQL是一个开源的关系型数据库管理系统. MySQL分为社区版本和企业版 MySQL安装方式: 1.MSI安装(Windows Installer) 2.ZIP安装 选择安装类型: 1.T ...
- PHP:第四章——PHP数组转换,统计,相关函数
<pre> <?php //数组转换,统计,相关函数 header("Content-Type:text/html;charset=utf-8"); //coun ...