You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
layui/examples/transfer.html

101 lines
2.7 KiB

6 years ago
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>穿梭框</title>
<link rel="stylesheet" href="../src/css/layui.css">
<style>
6 years ago
body{padding: 100px;}
6 years ago
#text1,#text2{padding-bottom: 60px;}
6 years ago
</style>
</head>
<body>
6 years ago
<div class="layui-btn-container">
<button type="button" class="layui-btn" lay-demo="getData">获取右侧数据</button>
<button type="button" class="layui-btn" lay-demo="reload">重载实例</button>
</div>
6 years ago
6 years ago
<div id="text1"></div>
6 years ago
<div class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label">职位</label>
<div class="layui-input-block">
<div id="text2"></div>
</div>
</div>
</div>
6 years ago
<div id="text3"></div>
<script src="../src/layui.js"></script>
<script>
6 years ago
layui.use(['transfer', 'util'], function(){
var $ = layui.$
,transfer = layui.transfer
,util = layui.util;
6 years ago
var ins1 = transfer.render({
elem: '#text1'
6 years ago
,title: ['候选文人', '获奖文人']
,data: [
{"value": "1", "title": "李白"}
,{"value": "2", "title": "杜甫"}
,{"value": "3", "title": "贤心"}
,{"value": "4", "title": "鲁迅", "disabled": true}
,{"value": "5", "title": "巴金"}
4 years ago
,{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"}
6 years ago
]
6 years ago
,id: 'demoId'
6 years ago
,value: ["2", "3"]
6 years ago
,showSearch: true
});
6 years ago
//按钮事件
util.event('lay-demo', {
getData: function(othis){
alert(JSON.stringify(ins1.getData()))
}
6 years ago
,reload: function(){
transfer.reload('demoId', {
value: ["6"]
4 years ago
//,data: [{"value": "1", "title": "李白"}]
6 years ago
});
}
6 years ago
});
var ins2 = transfer.render({
elem: '#text2'
6 years ago
,showSearch: true
6 years ago
,onchange: function(obj){
console.log(obj)
}
6 years ago
,parseData: function(res){
return {
"value": res.id
,"title": res.label
,"disabled": res.disabled
,"checked": res.checked
}
}
,data: [
{"id": "1", "label": "瓦罐汤"}
,{"id": "2", "label": "油酥饼"}
,{"id": "3", "label": "炸酱面"}
,{"id": "4", "label": "串串香", "disabled": true}
,{"id": "5", "label": "豆腐脑"}
,{"id": "6", "label": "驴打滚"}
]
,value: ["1", "5"]
6 years ago
});
});
</script>
</body>
</html>