赞
踩
一、html代码
- <div class="layui-form-item">
- <label class="layui-form-label">分类</label>
- <div class="layui-input-block" id="taglists">
- <input type="checkbox" name="" title="请选择分类" value="">
- </div>
- </div>
二、js代码
- <script>
-
- tags({$thread.fid});
- //标签查询
- function tags(fid){
- console.log(fid)
- $.ajax({
- url:"{:url('方法接口')}",
- data:{'fid':fid},
- type:"Post",
- dataType:"json",
- success:function(data){
- console.log(data);
- var getTpl = taglist.innerHTML
- ,view = document.getElementById('taglists');
- laytpl(getTpl).render(data, function(html){
- view.innerHTML = html;
- });
- form.render('checkbox'); //刷新select选择框渲染
- },
- error:function(data){
- $.messager.alert('错误',data.msg);
- }
- });
-
- }
-
- </script>
-
-
- <!--复选框渲染-->
- <script id="taglist" type="text/html">
- {{# layui.each(d.tag, function(index, item){ }}
-
- {{# if({$tagidsp} == 0 ){ }}
- <input type="checkbox" name="tag[]" title="{{item.name}}" value="{{item.tagid}}">
- {{# } else { }}
-
- {{# layui.each(toString({$thread.tagids}).split(','), function(indexs, items){ }}
-
- {{# if(items == item.tagid){ }}
- <input type="checkbox" name="tag[]" title="{{item.name}}" value="{{item.tagid}}">
- {{# } else { }}
- <input type="checkbox" checked name="tag[]" title="{{item.name}}" value="{{item.tagid}}">
- {{# } }}
-
- {{# }); }}
-
- {{# } }}
-
-
- {{# }); }}
-
- {{# if(d.tag.length === 0){ }}
- <input type="checkbox" name="" title="请选择分类" value="">
- {{# } }}
- </ul>
-
- </script>
三、后台的代码
- public function index($tid){
- $forum = '';//相关数组
- $post = ''; //相关数组
- $tagidsp = ''; //相关数组
- if(!$tagidsp){
- $tagidsp = '0';
- } else{
- $tagidsp = '1';
- }
- View::assign([
- 'name' => 'CMS管理系统',
- 'email' => '673011635@qq.com',
- 'thread' => $thread,
- 'forum' =>$forum,
- 'post' =>$post,
- 'tagidsp' =>$tagidsp,
- ]);
- return View::fetch('index');
-
- }
直接拿去就可以用适用于thinkphp所有系列以及使用thinkphp引擎的相关框架。
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。