/*
* jQuery CascadingSelect AddOption
*
* Author: luq885
* http://blog.csdn.net/luq885 (chinese) 
*
* Licensed like jQuery, see http://docs.jquery.com/License
*
* 作者：天天无用
* blog: http://blog.csdn.net/luq885
*/

(function($) {
    $.fn.CascadingInput = function(target, url, options, endfn) {
        debugger;
        $.ajaxSetup({ async: false });
        if (target[0] == undefined) return;
        //if (target[0].tagName != "SELECT") throw "target must be SELECT";
        if (url.length == 0) throw "request is required";
        //if(options.parameter == undefined) throw "parameter is required";

        this[0].onPropertyChange = function() {
            alert('qqqqqq');
            var newurl = "";
            var parameter = $(this).val();    //改造适用MVC
            if (parameter == '') {            //改造适用MVC
                parameter = 0;               //改造适用MVC
            }
            newurl = url + "/" + parameter;  //改造适用MVC
            target.FillOptions(newurl, options);
            if (typeof endfn == "function") endfn();
        } //);
    }
})(jQuery);

(function($) {
    $.fn.CascadingSelect = function(target, url, options, endfn) {
        //debugger;
        $.ajaxSetup({ async: false });
        if (target[0] == undefined) return;
        if (target[0].tagName != "SELECT") throw "target must be SELECT";
        if (url.length == 0) throw "request is required";
        //if(options.parameter == undefined) throw "parameter is required";

        this.change(function() {
            var newurl = "";
            var parameter = $(this).val();    //改造适用MVC
            if (parameter == '') {            //改造适用MVC
                parameter = 0;               //改造适用MVC
            }
            newurl = url + "/" + parameter;  //改造适用MVC
            target.FillOptions(newurl, options);
            if (typeof endfn == "function") endfn();
        });
    }
})(jQuery);

(function($) {
    $.fn.AddOption = function(text, value, selected, index) {
        option = new Option(text, value);
        this[0].options.add(option, index);
        this[0].options[index].selected = selected;
    }
})(jQuery);

