码迷,mamicode.com
首页 > 其他好文 > 详细

Bootstrap Multiselect 设置 option

时间:2015-07-28 12:49:18      阅读:2269      评论:0      收藏:0      [点我收藏+]

标签:

 $.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>
    <!-- 表单 -->
    <form id="form" action="" method="post" class="form-horizontal">
       <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">
                        <option value="{$vo.type_id}">{$vo.type_name}</option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">渠道<span class="check-tips">(请勾选渠道)</span></label>
            <div>
                <select id="channel" name="channel[]" multiple="multiple">
                    
                      
                    
                </select>
            </div>
        </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("change",function(){
        var platform_type_ids=$("#platform_type").val();//获取所有的平台类型
    
        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").nonSelectedText(v["cn_name"]);  $(‘#channel‘).append( $(‘<option></option>‘).text(v["cn_name"]).val(v["id"]) ); }); $(‘#channel‘).multiselect(‘rebuild‘) } }); }); </script> </block>

 

Bootstrap Multiselect 设置 option

标签:

原文地址:http://www.cnblogs.com/hgj123/p/4682280.html

(2)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!