1

嗨,我在上面的电话间隙中有代码。当我将列表附加到一个 div 中时。当我将该附加列表放入 id 时,我的滑块不会刷新。有没有人知道如何解决这个问题滑块是动态的。未修复。

<script>
    document.addEventListener("deviceready",getValue, false);

    function getValue() {
        var id = 0;
        var querystring = location.search.replace( '?', '' ).split( '&' );
        for ( var i=0; i < querystring.length; i++ ) {
            var name = querystring[i].split('=')[0];
            var value = querystring[i].split('=')[1];

            if(name == 'id') {
                var FoodID = value;
            }
        }

        var datastring ='&ID='+FoodID;
        alert(datastring);

        $.ajax({
            type:'POST',
            url:SITE_URL+'profile_foodprefs_settings.php',
            data:datastring,
            success:function(msg) {
                var data = $.parseJSON(msg);
                var rs = data.result;
                var j=0;
                for(j=0;j<rs.length;j++) {
                    var Name = rs[j].Name;
                    var ID = rs[j].ID;
                    var SelectID = rs[j].SelectID;

                    $("#toggleswitch"+ID+" option[value="+SelectID+"]").attr('selected','selected');
                    $("#food_detail").append('<div class="list_detbk" style="height: 65px!important;"><div class="top_toggle2"><div class="list_hdtxt"><label class="top_header2" style="padding-left: 12px;"><br />'+Name+'</label></div><div class="tglpos1"><select onclick="exclued_food('+ID+');"  name="toggleswitch1" id="toggleswitch'+ID+'" data-theme="a" data-role="slider" class="slider_refresh"><option value="0">No</option><option value="1">Yes</option></select></div></div></div>');
                }
            }
        });
    }
</script>
<body>
    <div data-role="page" id="profile_foodprefs_settings">
        <div data-theme="a" data-role="header" data-position="fixed">
            <h3>
                Proteins
            </h3>
            <a data-role="button" onclick="navigator.app.backHistory();" data-rel="back" data-theme="b">
                Cancel
            </a>
            <a data-role="button" data-theme="c" onclick="save_food_prefrences();" class="corner5" style="margin-top: -1px;">
                Save
            </a>
        </div>    
        <div style="float:left;margin:30px 0 15px 23px;">*Low-Fat Protein</div>
        <div class="hdtxt_rt">Include?</div>
        <div class="clear"></div>            
        <div id="content_refresh" data-role="content">
            <fieldset data-role="controlgroup" id="food_detail" style="margin-top:-10px;">
            </fieldset>
        </div>
    </div>
</body>
4

0 回答 0