在iOS网络应用程序中删除键盘上的搜索和去按钮 [英] Remove Search and Go Button on keyboard in iOS web app

查看:188
本文介绍了在iOS网络应用程序中删除键盘上的搜索和去按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JQuery Mobile编写了一个PhoneGap应用程序。



我根据在应用程式中点击的按钮和连结变更网页。我的所有视图都封装在一个单一的index.html页面中。不同的网页由div数据角色分解,如下所示:

 < div data-role =pageid =view1 >< / div> 

< div data-role =pageid =view2>< / div>

点击按钮时,应用会移动下一个视图:

  $ .mobile.changePage(#search2_1); 

问题是当用户在文本框中输入时。键盘弹出时提供Go或Search按钮。如果用户点击这个,他们绕过javascript函数,将它们移动到下一页,并不经意地发送回应用程序的根。



是否还有禁用或删除这些按钮,甚至有这些按钮触发更改页面功能?



*注意:因为这是一个PhoneGap应用程序,


解决方案

由于您的元素位于表单元素内,因此用户提交



您需要取消表单提交。



在jquery中看起来像这样:

  $(yourform)。submit(function(){
return false;
});


I am writing a PhoneGap app using JQuery Mobile.

I change pages based on buttons and links that are clicked within the app. All of my views are encapsulated in a single index.html page. Different pages are broken up by div data role like so:

 <div data-role="page" id="view1"></div>

 <div data-role="page" id="view2"></div>

When a button is clicked the app moves the next view with:

   $.mobile.changePage("#search2_1");

The problem is when a user is typing in a text box. The keyboard pops up with either the "Go" or "Search" buttons available. If the user clicks this, they bypass the javascript function that moves them to the next page and are inadvertently sent back to the root of the app.

Is there anyway to disable or remove these buttons or even have these buttons trigger the change page function?

*note: since this is a PhoneGap app I am limited in what I can do in Objective-C and I am focusing on doing this within the web page.

解决方案

Since your elements are inside a form element the user submits the form by pressing the search or go button, which will reload the page.

you need to cancel the form submit.

This would look something like this in jquery:

$("yourform").submit(function(){
     return false;
});

这篇关于在iOS网络应用程序中删除键盘上的搜索和去按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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