Jqweui多级联动

$.post("/getCollege", function (data) {
            if (data == null || data == undefined || data.length <= 0) {
                return false;
            }
            var datalist = new Array()
            for (var i = 0; i < data.length; i++) {
                var info = {"title": data[i].name, "value": data[i].id};
                datalist.push(info);
            }

            $("#selectCollege").select({
                title: "选择学院",
                items: datalist,
                onChange: function () {

                    var cid = $("#selectCollege").attr("data-values");
                    var grade = $("#selectGrade").attr("data-values")
                    $("#selectClass").attr("data-values", "");
                    $("#selectClass").attr("value", "");
                    $("#selectClass").val("")
                    if (cid == null || cid == undefined || cid.trim().length <= 0) {
                        return false;
                    }
                    if (grade == null || grade == undefined || grade.trim().length <= 0) {
                        return false;
                    }
                    $.post("/getClass?cid=" + cid + "&grade=" + grade, function (data) {
                        if (data == null || data == undefined || data.length <= 0) {
                            return false;
                        }
                        var datalist = new Array()
                        for (var i = 0; i < data.length; i++) {
                            var info = {"title": data[i].name, "value": data[i].id};
                            datalist.push(info);
                        }
                        $("#selectClass").select("update", {items: datalist});
                    })
                }
            })
        })

你可能感兴趣的:(Jqweui多级联动)