2013-05-02 42 views
1

我有一个JQuery Mobile/Phonegap应用程序。动态插入HTML表格元素后我打电话.trigger('create')包含元素上,像这样:动态内容只在JQuery Mobile/Phonegap中部分样式

$('div#response-form').append(formHtmlString).trigger('create'); 

所有元件被正确地风格除单选按钮和复选框,其中仅部分的风格和还没有正确对齐。请参见下面附加的图像:

Dynamic form in JQuery Mobile

这到底我做错了什么?

谢谢!

编辑

这是包含在formHTMLString变量的HTML代码:

<form data-response_id="API1201344135246"> 
<div data-page="1"> 
    <h3>Page One</h3> 
</div> 
<div data-role="fieldcontain"> 
    <fieldset data-role="controlgroup"> 
     <legend>Question - Checkbox*</legend> 
     <input type="checkbox" name="10010" id="10010" value="One" class="custom" /> 
     <label for="10010">One</label> 
     <input type="checkbox" name="10011" id="10011" value="Two" class="custom" /> 
     <label for="10011">Two</label> 
     <input type="checkbox" name="10012" id="10012" value="Three" class="custom" /> 
     <label for="10012">Three</label> 
    </fieldset> 
</div> 
<div data-role="fieldcontain"> 
    <label for="2">Question - String*</label> 
    <input type="text" name="2" id="2" value="" /> 
</div> 
<div data-role="fieldcontain"> 
    <fieldset data-role="controlgroup"> 
     <legend>Question - Radio Button</legend> 
     <input type="radio" name="6" id="10004" value="Yes" /> 
     <label for="10004">Yes</label> 
     <input type="radio" name="6" id="10005" value="No" /> 
     <label for="10005">No</label> 
     <input type="radio" name="6" id="10006" value="Maybe" /> 
     <label for="10006">Maybe</label> 
    </fieldset> 
</div> 

.... 

</form> 

回答

1

更新:

如果你想使用你的自定义主题/风格,负荷的jQuery - 移动设备的默认CSS并覆盖它的'样式。


增强的动态使用既.checkboxradio().trigger('create')复选框和单选按钮的标记。

复选框:

$('input[type=checkbox]').checkboxradio().trigger('create'); 

单选按钮:

$('input[type=radio]').checkboxradio().trigger('create'); 

Demo

+1

1为一个正确的答案 – Gajotres 2013-05-02 08:57:23

+0

'$('body')。trigger('create');'也可以在你的演示中使用(请参阅http://jsfiddle.net/X43HK/),但在我的应用程序中都不起作用,所以调用'在父容器上触发('创建')应该已经完成​​了。你会看到它是__partially__样式,所以它确实会做__something__。这个问题似乎有点复杂。任何其他想法? – 2013-05-02 09:58:47

+0

@raouldeveloper最好发布你的HTML标记。 – Omar 2013-05-02 14:26:26