We seem to have run into a problem with confirm box and jquery mobile. The following sample code illustrates the issue:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Punkt inventering</title>
</head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0-alpha.1/jquery.mobile-1.2.0-alpha.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<body>
<script >
function fire()
{
if ( confirm( "ok to continue? \n" ) )
{
document.myform.setthis.value = "1" ; //use setthis to pass back
document.myform.ok.value = "1";
document.myform.submit();
return true;
}
else
{
return false ;
}
}
</script>
<?php
// some bits and pieces
?>
<form id="myform" name="myform" action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
<?php echo "Artikel <input type=\"text\" value=\"".$id."\" maxlength=\"30\" name=\"id\" size=\"18\" >"; ?><br />
<?php echo "Lagerplats <input type=\"text\" size=\"10\" maxlength=\"10\" name=\"lagpl\" value=\"".$lagpl."\" \">"; ?><br />
Antal <input type="text" size="5" maxlength="6" id="ant" name="ant" ><br />
<input type="hidden" value="0" id="setthis" name="setthis" />
<input type="submit" id="ok" name="ok" class="knapp" value="inventera" /><br />
</form>
<?
$check = $_POST["setthis"];
echo "-----" . $validate . " .... " . $check . "<br />";
if ((isset($_POST['ok'])) )
{
$validate = 1;
echo "....." . $validate . " .... " . $check . "<br />";
// some validation
if ($validate > 0)
{
echo "....." . $validate . "<br />";
?>
<script language="Javascript">
fire();
</script>
<?
}
if (($check == 1) ) // pickup $check from hidden element setthis
{
// everything ok now we do some updates
}
}
?>
</body>
</html>
After selecting ok on the confim box the page just hangs - the javascript console indicates "
Uncaught TypeError: Cannot set property 'value' of undefined"
If we remove the line "<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>" then behavious is as we would expect - problem is that we don't get the mobile look and feel. Have tried with the 1.2 alpha code but the result is the same. Is this a bug or have we missed something ?
Thanks in advance for any help.