jquery:在.load()之后不应用移动样式

时间:2011-05-20 13:19:35

标签: jquery cordova jquery-mobile

$('#quest').click(function() {
                    $('#replaceit').load('class/cars.php?q=true',function(){$('#replaceit').collapsible('refresh');});

“无法在初始化之前调用可折叠的方法;尝试调用方法'刷新'”

生成的Html代码似乎工作正常,例如:

<div data-collapsed="true" data-role="collapsible">
<h1>Which warranty policy of the following is the best for you?</h1>
<p><input type="checkbox" value="2yearsunlimittedkilometers" name="question[Warranty][]">2 years unlimitted kilometers
<input type="checkbox" value="3yearsor60000kilometers" name="question[Warranty][]">3 years or 60000 kilometers
</p></div>

但它没有被称为可折叠:( ..任何线索?

1 个答案:

答案 0 :(得分:1)

看起来你错过了函数调用中的一些右括号

你有这个:

$('#quest').click(function() {
    $('#replaceit').load('class/cars.php?q=true',function() {
        $('#replaceit').collapsible('refresh');
});

看起来应该是这样的:

$('#quest').click(function() {
    $('#replaceit').load('class/cars.php?q=true',function() {
        $('#replaceit').collapsible('refresh');
    })
});

我也从未见过这个:

collapsible('refresh')

您能提供相关文档/示例吗?

也许试试:

$('#replaceit').collapsible().page();

HTML标记的替代语法:实例:http://jsfiddle.net/Rj6AW/4/

<div data-role="page" id="home"> 
    <div data-role="content"> 
        <div data-collapsed="true" data-role="collapsible">
            <legend>Which warranty policy of the following is the best for you?</legend>
            <fieldset data-role="controlgroup" data-role="fieldcontain">                
                <input type="checkbox" value="2yearsunlimittedkilometers" name="question[Warranty][]" id="2yearsunlimittedkilometers" />
                <label for="2yearsunlimittedkilometers">2 years unlimitted kilometers</label>
                <input type="checkbox" value="3yearsor60000kilometers" name="question[Warranty][]" id="3yearsor60000kilometers" />
                <label for="3yearsor60000kilometers">3 years or 60000 kilometers</label>
            </fieldset>
        </div>
    </div>
</div>