jQuery Mobile - 动态创建表单元素 [英] jQuery Mobile - Dynamically creating form elements

查看:157
本文介绍了jQuery Mobile - 动态创建表单元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个针对iOS设备的网络数据库驱动的离线网络应用。我正在尝试使用jQuery Mobile,但是我在创建各种表单时遇到了问题。

I'm creating a web-database driven offline web-app targeted at iOS devices. I'm trying to use jQuery Mobile, but I have a problem in creating the various forms.

表单选项取自数据库查询,因此它们被插入到加载后的页面,所以jQuery-Mobilification不会发生。快速查看源代码,在这个阶段似乎没有任何明显的方法可以调用它(当然它是alpha版本,我认为这将是一个相当普遍的请求,所以我希望它将会来)。我可以采用某种解决方法吗?我对单选按钮,复选框和选择列表特别感兴趣。

The form options are taken from a database query, so they are inserted into the page after it has loaded, so the "jQuery-Mobilification" doesn't happen. Taking a quick look through the source, there doesn't seem to be any obvious way to call into this at this stage (of course it's an alpha release, and I think this would be a reasonably common request, so I'm hopeful it will come). Is there some kind of workaround I can put in to do this? I'm particularly interested in radio buttons, check boxes and select lists.

推荐答案

这在无证内幕中乱七八糟,但是以下是为我工作:

This is messing around in undocumented internals, but the following is working for me:

$("#some-div").load("/html/fragment/", 
                    function() { 
                      $(this).find("input").customTextInput();  
                    });

有按钮,复选框等等的方法。

There are equivalent methods for buttons, checkboxes etc.

_enchanceControls [sic]方法。 mobile-1.0a1.jsrel =nofollow> http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.js

Have a look at the _enchanceControls [sic] method in http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.js.

1.0Alpha2的更新:在使用库的内部时可以预期,这在最新版本中不再有效。将 customTextInput()更改为 textinput()修复了一下,但主题因某些原因未完全应用。我们被警告了......

Update for 1.0Alpha2: As can be expected when playing around with the internals of a library, this no longer works in the latest version. Changing customTextInput() to textinput() fixes it a bit, but the theme isn't fully applied for some reason. We were warned...

这篇关于jQuery Mobile - 动态创建表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆