Jquery Mobile:排序后禁用单选按钮

时间:2013-06-01 20:21:21

标签: jquery jquery-mobile

我有3个问题需要以随机顺序呈现,所有3个都是单一选择:Q1,Q2和Q3。使用DIV对它们进行排序后,所有单选按钮都将被禁用。这是标记和JS: .................................................. .................................................. .................

<div id='wrapper'>

<div class='question'>

    <div><h4>Q1. Select favorite color</h4></div>

    <fieldset data-role='controlgroup' id='V13'>
    <input id ='V13_1' type='radio' name='V13' value='1'><label for='V13_1'> blue</label>
    <input id ='V13_2' type='radio' name='V13' value='2'><label for='V13_2'> red</label>
    <input id ='V13_3' type='radio' name='V13' value='3'><label for='V13_3'> yellow</label>
    </fieldset>

</div>

<div class='question'>

    <div><h4>Q2. Select sex</h4></div>

        <fieldset data-role='controlgroup' id='V14'>            
        <input id ='V14_1' type='radio' name='V14' value='1'><label for='V14_1'> male</label>
        <input id ='V14_2' type='radio' name='V14' value='2'><label for='V14_2'> female</label>
        </fieldset>

   </div>

<div class='question'>

    <div><h4>Q3. Select car</h4></div>

    <fieldset data-role='controlgroup' id='V15'>
    <input id ='V15_1' type='radio' name='V15' value='1'><label for='V15_1'> Ford</label>
    <input id ='V15_2' type='radio' name='V15' value='2'><label for='V15_2'> Toyota</label>
    <input id ='V15_3' type='radio' name='V15' value='3'><label for='V15_3'> None</label>
    </fieldset>

</div>

</div>

// THIS FUNCTION WORKS FINE, THIS IS NOT THE PROBLEM
function shuffleArray(d){for(var c=d.length-1;c>0;c--){var b=Math.floor(Math.random()*(c+1));var a=d[c];d[c]=d[b];d[b]=a}return d};       


// THIS FUNCTION SORT DIVS, THIS MIGHT BE THE PROBLEM

$(document).ready(function(){
    var MyArray = shuffleArray($('.question'));
    $('#wrapper').html('');
    for (var a = 0; a < MyArray.length;a++) {
        $('#wrapper').append(MyArray[a]);
    }
});

http://jsfiddle.net/QfYug/35/

1 个答案:

答案 0 :(得分:0)

我只删除$('#wrapper')行.html('');

虽然我担心副作用,但它似乎正在起作用......