For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 12 replies, 3 voices, and was last updated 12 years, 6 months ago by
Robert Gardner.
-
AuthorPosts
-
Robert GardnerParticipantHello Mobi’ers,
I have a text field that I want to ensure is blank each time the application is started. How do I accomplish this?
Thanks in advance for your input.
September 9, 2013 at 10:34 am #342244
BrandonMemberIn your custom_js file you will find an on document loaded function. In there you can place something like this:
$(‘#m1-yourformname-textField1’).val(”);
which will set the textfield with no value.
September 9, 2013 at 10:42 am #342245
Robert GardnerParticipantSilly question…. where is the file you’re referencing?
September 9, 2013 at 10:55 am #342246
support-michaelKeymasterHere is an expanded version of Cincyplanets example. I assume you have an input field widget who’s ID property ends in Field1, e.g., TextField1. The code below is included in the <project>_custom.js file generated by mobione in the <project>_www/ directory.
/** * Called when document is loaded. */ phoneui.documentReadyHandler = function() { document.addEventListener("deviceready", onDeviceReady, false); } //called when cordova has initialized function onDeviceReady() { document.addEventListener("resume", onDeviceResume, false); clearInput(); } //called when the app resumes from background function onDeviceResume() { clearInput(); } //set the inputfield widget's text to empty string function clearInput() { $('[id$=Field1]').val(''); }September 9, 2013 at 11:01 am #342247
BrandonMember@Wayne
Great sample, I modified it a bit for the mobius blog: http://cincyplanet.com/mobius/September 9, 2013 at 11:21 am #342248
Robert GardnerParticipantHummm… I attempted to add the code you suggested.. Clearly I must be doing something wrong. It doesn’t clear the text… What am I missing?
Thank you
Attachments:
You must be logged in to view attached files.September 9, 2013 at 11:25 am #342249
BrandonMemberYou need these lines as they initiate the clearing on startup:
* Called when document is loaded.
*/
phoneui.documentReadyHandler = function() {
document.addEventListener(“deviceready”, onDeviceReady, false);
}//called when cordova has initialized
function onDeviceReady() {
document.addEventListener(“resume”, onDeviceResume, false); //ONLY NEED TO CLEAR ON RESUME
clearInput();
}September 9, 2013 at 11:38 am #342250
Robert GardnerParticipantCut and pasted your input to my custom.js file. Saved the updated file and rebuilt the app. I clearly am overlooking something.. It’s not clearing the text. 🙁
I’ve included the complete custom.js file for my project for review…(minus the comments at the top)
Thanks,
Attachments:
You must be logged in to view attached files.September 9, 2013 at 12:26 pm #342251
BrandonMemberTry pasting this, make sure you dont have any double functions:
/**
* Called when document is loaded.
*/
phoneui.documentReadyHandler = function() {
document.addEventListener(“deviceready”, onDeviceReady, false);
}//called when cordova has initialized
function onDeviceReady() {
document.addEventListener(“resume”, onDeviceResume, false);
clearInput();
}//called when the app resumes from background
function onDeviceResume() {
clearInput();
}//set the inputfield widget’s text to empty string
function clearInput() {
$(‘[id$=LegNote]’).val(”);
}September 9, 2013 at 2:38 pm #342259
Robert GardnerParticipantYou win all the points… 🙂 That did it… I’ll have to review in detail to see what I did incorrectly the first couple of times…
Thank you!
September 10, 2013 at 7:55 am #342279
Robert GardnerParticipantBonus round follow up question…..If I want to clear another text field where do I place the additonal code in the custome .js
This is the last line in the custom.js file. Do I duplicate all this or can I embed the code in the existing function?
//Clear the LegNote text each time app is resumed
function clearInput() {
$(‘[id$=LegNote]’).val(”);
}Also, where can I read up on the phone functions described in the custom.js file…
Thanks again in advance for your input..
September 10, 2013 at 11:22 am #342284
BrandonMemberGlad I could help.
You can place it in the same function:
Good Learning resources are:
http://www.genuitec.com/mobile/learningcenter.php
http://cincyplanet.com/mobius
http://cincyplanet.com/mobione/and, for more advanced Cordova functions and features:
http://docs.phonegap.comand for basic javascript learning:
http://www.w3schools.comSeptember 10, 2013 at 5:13 pm #342289
Robert GardnerParticipantThank you again!
-
AuthorPosts
