PhoneGap刷新div

时间:2012-08-19 07:09:33

标签: cordova

嗨我上面有电话间隙的代码。当我将列表添加到一个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>

0 个答案:

没有答案