Hi,
I am a beginner of JQuery and JQTouch reading the book "Building Android App with HTML5, CSS and Javascript". I try to run the example in the book but run into a problem of the submit function is not being captured. I have checked this forum and it seems that there seems to be no obvious answer (or obvious common syntax errors).
It seems that my function createEntry() is not being captured by statement $('createEntry form').submit(createEntry); In my coding become I can see the alert message Check Point 1 and 2 but I never got to Check Point 3.
Can anyone help?
function createEntry() {
alert('Check Point 3');
var date = sessionStorage.currentDate;
var calories = $('#calories').val();
var food = $('#food').val();
db.transaction(
function(transaction) {
transaction.executeSql(
'INTSERT INTO entries (date, calories, food) VALUE (?, ?, ?);',
[date, calories, food],
function(){
refreshEntries();
jQT.goBack();
},
errorHandler
);
}
);
return false;
}
.........
$(document).ready(function(){
alert('Check Point 1');
$('#createEntry form').submit(createEntry);
alert('Check Point 2');
$('#settings form').submit(saveSettings);
......
<body>
....
<div id="createEntry">
<div class="toolbar">
<h1>New Entry</h1>
<a class="button cancel" href="#">Cancel</a>
</div>
<form method="post">
<ul class="rounded">
<li><input type="text" placeholder="Food" name="food" id="food"
autocapitalize="off" autocorrect="off" autocomplete="off" /></li>
<li><input type="text" placeholder="Calories" name="calories" id="calories"
autocapitalize="off" autocorrect="off" autocomplete="off" /></li>
<li><input type="submit" class="submit" name="action" value="Save" /></li>
</ul>
</form>
</div>
.....
</body>