Last active
December 13, 2015 17:58
-
-
Save Elexy/4951709 to your computer and use it in GitHub Desktop.
Qooxdoo Mobile form submit with Iphone / ipad keyboard The idea is to create a html form that wraps the qx.ui.mobile.form.Form.
The HTML form has a hidden submit button so that IOS recognizes the form as something it could submit with the keyboard. I tested it on Ipad1 and on the desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ************************************************************************ | |
#use(qx.ui.mobile.core.EventHandler) | |
************************************************************************ */ | |
/** | |
* This is the base class for all mobile widgets. | |
*/ | |
qx.Class.define("sgmobile.widget.HtmlForm", { | |
extend: qx.ui.mobile.container.Composite, | |
events: { | |
enter: 'qx.event.type.Data' | |
}, | |
/* | |
***************************************************************************** | |
MEMBERS | |
***************************************************************************** | |
*/ | |
members: { | |
/** | |
* Returns the tag name of the container element of this widget. | |
* Override this method if you want to create a custom widget. | |
* @return {String} The container element's tag name | |
*/ | |
_getTagName: function() { | |
return "form"; | |
}, | |
/** | |
* Creates the container DOM element of the widget. | |
* Override this method if you want to create a custom widget. | |
* | |
* @return {Element} the container element. | |
*/ | |
_createContainerElement: function() { | |
var form = qx.dom.Element.create(this._getTagName()); | |
qx.event.Registration.addListener(form, "keypress", function(e) { | |
if(e.getKeyCode() == 13) { | |
e.preventDefault(); | |
e.getTarget().blur(); | |
this.fireEvent('enter'); | |
} | |
}, this, false); | |
var submitDiv = qx.dom.Element.create('div'); | |
submitDiv.setAttribute('class', 'hidden-submit') | |
var submit = qx.dom.Element.create('input'); | |
submit.setAttribute('type', 'submit'); | |
submitDiv.appendChild(submit) | |
form.appendChild(submitDiv); | |
return form; | |
} | |
}, | |
destruct: function() { | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qx.Class.define("sgmobile.page.Login", | |
{ | |
extend : qx.ui.mobile.page.NavigationPage, | |
properties: { | |
}, | |
members : { | |
// overridden | |
_initialize : function() { | |
this.base(arguments); | |
var title = new qx.ui.mobile.form.Title("Please enter your credentials"); | |
this.getContent().add(title); | |
var form = this.__form = new qx.ui.mobile.form.Form(); | |
var email = this.__input = new qx.ui.mobile.form.TextField(); | |
email.setPlaceholder("Email address"); | |
email.setRequired(true); | |
form.add(email, "Email"); | |
var password = this.__password = new qx.ui.mobile.form.PasswordField(); | |
password.setPlaceholder("Password"); | |
password.setRequired(true); | |
form.add(password, "Password"); | |
var htmlForm = new sgmobile.widget.HtmlForm(); | |
htmlForm.add(new qx.ui.mobile.form.renderer.Single(form)); | |
var manager = form.getValidationManager(); | |
manager.add(email, qx.util.Validate.email()); | |
var controller = this._controller = new qx.data.controller.Form(null, form); | |
var model = this._model = controller.createModel(); | |
var button = new qx.ui.mobile.form.Button("Login"); | |
button.addListener("tap", this._onTap, this); | |
htmlForm.add(button); | |
htmlForm.addListener("enter", this._onTap, this); | |
this.getContent().add(htmlForm); | |
}, | |
_onTap : function(evt) | |
{ | |
if(this.__form.validate()){ | |
this.fireDataEvent("login", this._model); | |
} | |
} | |
}, | |
events : { | |
"login" : "qx.event.type.Data" // Define the event | |
}, | |
construct : function() { | |
this.base(arguments); | |
this.setTitle("Field 360"); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.hidden-submit { | |
border: 0 none; | |
height: 0; | |
width: 0; | |
padding: 0; | |
margin: 0; | |
overflow: hidden; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment