Refresh dynamic jquery multiple select menu not working

Viewed 4611

happy new year. i have a multiple select list i am trying to build (data-native-menu="false") the and are dynamically added through a websql query. when i run the code, it does not add any of the options anyhere to the page. when i remove the multiple="multiple" data-native-menu="false" attributes the code works great and adds the data as it is supposed to do. i have tried adding

$("#addequip_form_equip").selectmenu().selectmenu({'refresh': true});
$("#addequip_form_equip").({'refresh': true});
$("#addequip_form_equip").('refresh': true');
$("#addequip_form_equip").selectmenu('refresh');

and several other variations. no console logs are displayed so i believe the problem is somewhere with the refresh since the code seems to append to the list without the other attributes. i have consulted the jquery docs and read several other posts here and am not able to solve this problem, i appreciate any assistance. code is as follows

HTML

<div data-role="fieldcontain">
<label for="addequip_form_equip" class="select">Select Equipment:</label>
<select name="addequip_form_equip" id="addequip_form_equip" multiple="multiple" data-native-menu="false">       
<option>Select Equipment</option>
</select>
</div>

JS

function shotlists_open_addequip(sl_id) {
    console.log("shotlists_open_addequip function ran");
    var user_id = window.localStorage.getItem("PSLui");

    // perform db entries
    db.transaction(function(tx) 
    {
        tx.executeSql("SELECT * FROM shotlists_equipment WHERE user_id=? AND shotlist_id=?", [user_id, sl_id] , function(tx, results) {
        var len = results.rows.length;
        console.log("shotlists_equipment: " + len + " rows found.");

        // check if equipment shotlist already exists
        if(len=='1')
        {
            // todo: make alert native with phonegap notification api
            alert("Only One Equipment Check List Allowed");
            // based on api when user clicks ok redirect to shotlists page
            loadShotlists();
            $.mobile.changePage("#shotlists");
        } else {

        db.transaction(function(tx) 
        {
            tx.executeSql('SELECT * FROM equipment_cats', [], function (tx, results)
            {

                var len = results.rows.length;
                var txt="";
                for (var i=0; i<len; i++){
                $("#addequip_form_equip").append("<optgroup id='"+results.rows.item(i).cat_id+"' label='"+results.rows.item(i).cat_name+"'></optgroup>");

                }
            });

            tx.executeSql('SELECT * from equipment WHERE user_id=?', [user_id], function (tx, results)
            {
                var len = results.rows.length;
                var txt="";
                for (var i=0; i<len; i++){
                $("#addequip_form_equip optgroup[id="+results.rows.item(i).cat_id+"]").append("<option value="+results.rows.item(i).websql_id+">"+results.rows.item(i).name+"</option>");

                }
            $("#addequip_form_equip").selectmenu("refresh");
            });         

        });

    }

    }); 
    }); 
}

EDIT

when inspecting the element, this is the html that is generated, i am not very familiar with this widget but it looks like everything is being populated where it belongs.

<div data-role="fieldcontain" class="ui-field-contain ui-body ui-br">
    <label for="addequip_form_equip" class="select ui-select">Select Equipment:</label>
    <!--    <select name="addequip_form_equip" id="addequip_form_equip" multiple="multiple" data-native-menu="false"> -->
    <div class="ui-select">
        <a href="#addequip_form_equip-listbox" role="button" id="addequip_form_equip-button" aria-haspopup="true" aria-owns="addequip_form_equip-menu" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-icon="arrow-d" data-iconpos="right" data-theme="c" class="ui-btn ui-shadow ui-btn-corner-all ui-btn-icon-right ui-li-has-count ui-btn-up-c" data-rel="popup"><span class="ui-btn-inner"><span class="ui-btn-text"><span>Select Equipment</span></span><span class="ui-icon ui-icon-arrow-d ui-icon-shadow">&nbsp;</span></span><span class="ui-li-count ui-btn-up-c ui-btn-corner-all" style="display: none;">0</span></a>
        <select name="addequip_form_equip" id="addequip_form_equip" multiple="multiple" data-native-menu="false" tabindex="-1">
            <option data-placeholder="true">Select Equipment</option>
            <optgroup id="1" label="Accessories">
            <option value="1">Light Meter</option>
            <option value="2">Circular Reflector Disc</option>
            </optgroup><optgroup id="2" label="Backgrounds">
            <option value="3">Muslin Background</option>
            <option value="4">Muslin Background</option>
            <option value="5">Muslin Background</option>
            </optgroup><optgroup id="3" label="Camera Bodies">
            <option value="6">Nikon D4</option>
            <option value="7">Nikon D800</option>
            <option value="8">Canon EOS 5D Mark III</option>
            <option value="9">Canon EOS Rebel XSi</option>
            </optgroup><optgroup id="4" label="Lenses">
            <option value="10">Canon EF 14mm f/2.8L II USM</option>
            <option value="11">Canon EF 28-300mm f/3.5-5.6L IS USM</option>
            <option value="12">Nikon AF Nikkor 80-400mm f/4.5-5.6D ED VR</option>
            <option value="13">Nikon 1 Nikkor VR 10-100mm f/4.5-5.6</option>
            </optgroup><optgroup id="5" label="Lighting">
            <option value="14">Profoto D1 Air 500W/s Monolight</option>
            <option value="15">Profoto B1 500 AirTTL Battery Powered Flash </option>
            </optgroup>
        </select>
        <div style="display: none;">
            <!-- placeholder for addequip_form_equip-listbox -->
        </div>
    </div>
</div>
1 Answers
Related