jQuery Mobile忽略data-role ="none"在表单元素上 [英] jQuery Mobile ignoring data-role="none" on form elements
问题描述
我正在将页面动态注入到jQuery Mobile应用程序中.除了表单元素,其他所有东西都工作正常.似乎在已插入页面上的表单元素上忽略了data-role ="none".
I'm dynamically injecting pages into my jQuery Mobile app. Everything is working fine, except form elements. It seems that data-role="none" is being ignored on form elements that are on the injected pages.
<p><input data-role='none' type='radio' name='type' id='type' value='none'/>None</p>
<p><input data-role='none' type='radio' name='type' id='type' value='segments'/>Market Segments</p>
<p>   <select data-role='none' id='segments'><option value='all'>All</option></select></p>
单选按钮呈现为常规单选按钮,尽管格式有些混乱.选择按钮应显示为常规下拉列表,但将呈现为jQuery Mobile下拉列表.
The radio buttons render as regular radio buttons, albeit with some screwy formatting. The select button should appear as a regular dropdown, but it is being rendered as a jQuery Mobile dropdown instead.
这是页面注入的方式:
var t = results.rows.item(i).body;
var n = results.rows.item(i).name;
$("#"+n).remove();
$("body").append(t);
$("#"+n).appendTo($.mobile.pageContainer);
$("#"+n).attr('data-url',$("#"+n).attr("ID")).trigger('create');
未注入页面上的表单元素运行正常……有什么想法吗?
Form elements on non-injected pages are working fine... any ideas?
推荐答案
默认情况下,如果您想告诉JQM 属性添加到容器中,但是您也需要设置$.mobile.ignoreContentEnabled = true
.这样做的原因是因为默认情况下,JQM不会检查data-role="none"
属性(以免每次都不必要地执行检查).
By default jQuery Mobile will auto enhance form elements, if you want to tell JQM to ignore them you can add the data-role="none"
attribute to the container, however you also need to set $.mobile.ignoreContentEnabled = true
. The reason for this is because by default JQM doesn't check for the data-role="none"
attribute (so as to not perform a check every time needlessly).
请记住,您需要在 mobileinit event
.
这篇关于jQuery Mobile忽略data-role ="none"在表单元素上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!