controlgroup('refresh')不起作用

时间:2015-06-11 20:13:33

标签: jquery jquery-mobile

我在使用enhanceWithin()和controgroup('refresh')时遇到问题。我上个月发布了一个关于类似事情的问题(link)我得到了帮助,但是当我尝试应用我所理解的东西时,它就无法工作。

我的问题是我希望测验中所有可能的答案看起来像这样link 2现在我只用一个问题做了这个,但现在我想做多个问题。这就是我所做的link

$(document).ready(function() {

    var responseText = '{"title":"quiz 3","qid":"63375","qno":"5","dur":"0:30","no":["1","2","3","4","5"],"ques":["test 12","test 324","test 93jk","test5","4gvgfghfgjfjhg"],"a":["bnvbnvn","uyiugyukf","hgd",";opoippoidfd","nbmmnmbn"],"b":["mhhhhm","hjfi","fgfg","uoyurtyytd","fghhvb"],"c":["nmnmnmmn","rythj"," bnbnvbnvbnv","yutuddyc","vmbvmj"],"d":["nnn","iiii","hghjghjmm","yuitdtydddy","vvv"],"e":["mkkmkm","hnvhjnbmhn","gfdrdyrttyjk","45","bnvcnvb"]}';

    var json = $.parseJSON(responseText);
    var title = json['title'];
    var duration = json['dur'];
    var no = json['qno'];
    var ques_m = json['ques'];
    var a = json['a'];
    var b = json['b'];
    var c = json['c'];
    var d = json['d'];
    var e = json['e'];

    var j = 1 //question counter
    var i = 0 // array counter

    while (no > i) {  

        var div = $("<div />");
        var ques = "<p id='ques" + i + "' placeholder='Enter Question Here.'>" + ques_m[i] + "</textarea>";

        var ans_div = $("<div />");
        var ans_a = "<label>" + a[i] + "</label><input type='radio' name='possans" + j + "' id='aans" + i + "' value='" + a[i] + "'/>";
        var ans_b = "<label>" + b[i] + "</label><input type='radio'   name='possans" + j + "'  id='bans" + i + "'value='" + b[i] + "'/>";
        var ans_e = "<label>" + e[i] + "</label><input type='radio'   name='possans" + j + "' id='eans" + i + "' value='" + e[i] + "'/>";
        var ans_c = "<label>" + c[i] + "</label><input type='radio'   name='possans" + j + "' id='cans" + i + "' value='" + c[i] + "'/>";
        var ans_d = "<label>" + d[i] + "</label><input type='radio'   name='possans" + j + "' id='dans" + i + "' value='" + d[i] + "'/>";

        $(ans_div).append(ans_a).append(ans_b).append(ans_c).append(ans_d).append(ans_e);
        $(div).append("Q(" + j + ")").append(ques).append(ans_div);
        i++;
        j++;
        $("#qu").append(div).append("<hr/><br>");
    }

    $("#qu").append("<input type='button' value='Update'onclick='sub()' id='submit'/><input type='hidden' id='count' value='" + no + "'/>");
    $("#qu").enhanceWithin().controlgroup('refresh');

});

1 个答案:

答案 0 :(得分:1)

您忘记将<input>分配给每个<label>:您必须使用for属性。

请参阅 updated JSFiddle