表单提交 jQuery 移动
我已经意识到移动应用程序不喜欢像 html 那样的表单提交方式,所以我想我最好在 Stackoverflow 上进行一次健全性检查。
例如,我现在应该使用 而不是
问:我可以继续使用对于移动应用程序?
我之所以这么问,是因为action页面有一些逻辑,比如:
<cfif structKeyExists(form,"Save")>
I've gotten it into my head that mobile applications don't like form submits the same way html does, so I thought I'd better have a sanity check on Stackoverflow.
For example, instead of having <input type="submit"...>, it looks like I should now use <a data-role="button"...>
Q: Can I continue to use <input type="submit"...> for mobile applications?
The reason why I ask is because the action page has some logic, such as:
<cfif structKeyExists(form,"Save")>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jQuery Mobile,至少在撰写本文时,默认情况下使用在提交的表单上指定的方法通过 AJAX 提交表单。 POST 提交仍会在后台发布到服务器,因此 ColdFusion 仍会像往常一样看到传入的表单变量。生成响应后,jQuery Mobile 将获取响应并将视图转换为返回的任何 HTML。在我自己的测试中,您也可以继续使用普通的提交按钮。如果您想要标准提交而不是 AJAX 提交,请将
data-ajax="false"
添加到表单标记。jQuery Mobile, at least as of this writing, by default submits forms via AJAX using the method specified on the form being submitted. POST submissions will still be posted to the server in the background, so ColdFusion will still see the form variables that are passed in as usual. When a response is generated, jQuery Mobile will take the response and transition the view over to whatever HTML was returned. In my own testing you can continue to use a normal submit button as well. If you want a standard submission rather than an AJAX submission, add
data-ajax="false"
to the form tag.如果您想以编程方式提交表单,请将表单的
data-ajax
属性设置为false
,然后为submit
设置事件处理程序表单的事件:If you want to programatically submit a form, set the
data-ajax
attribute for the form tofalse
and then set an event handler for thesubmit
event for the form: