@model string
<div class="main">
    <form class="form-horizontal form">
        <div class="control-group">
            <label class="control-label">站点</label>
            <div class="controls form-inline form-group-sm">
                <select id="site_id" name="site_id" class="form-control"></select>
                <span class="help-block"></span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">栏目</label>
            <div class="controls form-inline form-group-sm">
                <select id="column_id" name="column_id" class="form-control"></select>
                <span class="help-block"></span>
            </div>
        </div>
        <div class="control-group text-center">
            <label class="control-label"></label>
            <div class="controls form-inline" style="padding:0px;">
                <button type="button" class="btn btn-primary btn-sm set_submit" id="bt_submit">确定</button>
                <span class="help-block"></span>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    //填充站点下拉
    var params = { valueField: 'id', textField: 'name' };
    var listJson = CallAjax("get", false, "@Url.Action("ListData", "Site")");
    $("#site_id").FillSelect(eval(listJson), params);



    @*绑定数据
    var id =Request("id");
    if (id != "")
    {
        var ajaxUrl = "@Url.Action("DetailData", "CollectionContent")?id="+id;
        $(".form").FormBind(data);
    }*@

    $(function () {
        var $column_id = $("#column_id");
        //填充栏目下拉
        ColumnBinding($("#site_id").children("option:selected").val())

        $("#site_id").change(function () {
            ColumnBinding($(this).val())
        })
        var parent_pagePost = parent.$(".ui-pagePost.DetailRule")
        $(".set_submit").click(function () {
            var $site_id_val = $("#site_id").children("option:selected").val();
            parent.$("#site_id").val($site_id_val);
            var $column_id_val = $("#column_id").children("option:selected").val();
            if ($column_id_val == "") {
                CloseDialog();
            } else{
                parent.$("#column_id").val($column_id_val)
                CloseDialog();
                parent_pagePost_params = parent_pagePost.attr("data-custom-params");
                parent_pagePost.attr("params", "url:'@Url.Action("DetailRule")',callBack:'PostRefreshBack'");
                parent_pagePost.click();
                parent_pagePost.attr("params", parent_pagePost_params);
            }
        })

    })
    function ColumnBinding(site_id)
    {        
        var $column_id = $("#column_id");
        $column_id.children("option").remove();
        var params = { valueField: 'id', textField: 'name' };
        var listJson = CallAjax("get", false, "@Url.Action("ListData", "Collection")?site_id=" + site_id);
        if (listJson == "") {
            listJson = [{ "id": "", "name": "当前站点没有设置目录" }];
            $column_id.FillSelect(eval(listJson), params);
        } else
        {           
            $column_id.FillSelect(eval(listJson), params);
        }
    }
</script>
