TypeError:对象不支持选择的属性或方法'在IE10 / IE11中

时间:2014-12-02 14:08:18

标签: javascript jquery internet-explorer

Internet Explorer提供错误,它不支持所选方法或属性。它在chrome和firefox中工作正常。这有什么替代品吗? TypeError:对象不支持选择的属性或方法'    在匿名函数(评估代码:37:17)    在j(https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js?_=1417526805748:2:27128

function setFocusOnLoad() {}    // This will disable the auto opening of the Select List when page loads.
            $(document).ready(function(){
            // Dynamically create the Select List and options
            var select = $('<select class="selectDiv" id="selectPickList{!Unique}" multiple>');

            var hasAllOption{!Unique}       = {!All};
            var hasAllByDefault{!Unique}    = {!All_Default};
            var allName{!Unique}            = '{!All_Name}';
            //alert('hi');
            if(allName{!Unique} == '')
                allName{!Unique} = 'None Selected';   


            if(hasAllOption{!Unique}){
                if(hasAllByDefault{!Unique})
                    select.append('<option value="" selected>'+allName{!Unique}+'</option>');        
                else
                    select.append('<option value="" selected>'+allName{!Unique}+'</option>'); 
            }

            <apex:repeat value="{!Picklist}" var="p">
                select.append('<option value="{!p}" >{!Picklist[p]}</option>');

            </apex:repeat>
            var selSize = $('select[id^="selectPickList{!Unique}"]');
            if(selSize.length == 0){
                $('#selectDiv{!Unique}').append(select);
            }
            var width{!Unique}  = '{!width}';
            if(width{!Unique} == '')
                    width{!Unique} = '50%'; // default is 50%

            // Initialize the chosen for every Component used. Uniqueness is very important 
            var chosen{!Unique} = $("#selectPickList{!Unique}").chosen({
                  no_results_text: "No results matched",
                  create_option: false,
                  width: width{!Unique},
                  placeholder_text_multiple: "Select or Search.."
            });

            // Add the change event. 

            $("#selectPickList{!Unique}").on('change', function(evt, params) {

                if(params.selected == ''){ // if All is selected remove the rest

                    var arrVals = $("#selectPickList{!Unique}").val(); 

                    arrVals = [''];

                    $("#selectPickList{!Unique}").val(arrVals);

                    chosen{!Unique}.trigger("chosen:updated");



                }else{ // If something else is selected remove the All. So the ALL & Rest is mutually exclusive


                    var arrVals = $("#selectPickList{!Unique}").val();                        
                    for(var i=0;i<arrVals.length;i++){
                        if(arrVals[i] == ''){
                            arrVals.splice(i,1);
                        }
                    }
                    $("#selectPickList{!Unique}").val(arrVals);
                    chosen{!Unique}.trigger("chosen:updated");

                }

                selected{!Unique} = $('#selectPickList{!Unique}').val(); // Set this for using from Visualforce page
                if('{!Page_Element_Id}' != '')
                    document.getElementById("{!Page_Element_Id}").value = selected{!Unique};
            });

            var selected{!Unique} = $('#selectPickList{!Unique}').val(); // Very important variable. that can used from a visualforce page. 
            if('{!Page_Element_Id}' != '')
                    document.getElementById("{!Page_Element_Id}").value = selected{!Unique};
        });

0 个答案:

没有答案
相关问题