複数ページのドキュメントがありますが、htmlを表示し、1つのphpファイル内の単一ページの検証を行っています。
<div id="checkPage" data-role="page">
<div data-role="header">
<h1>Page Title</h1>
</div>
<div data-role="content">
<?php
$form = $_REQUEST['form']; //this is simply a hidden input in my form that I reference to know if a form submission has occurred
if($form) {
$res = process();
if(is_array($res)) { //if the data is an array then it is an array of errors that I will display to the user
$html = page($res);
} else {
$html = $res; //if the data is not an array then it is confirmation html that the request was successful.
}
} else {
$html = page();
}
echo $html;
?>
</div>
</div>
私のpage()関数では、HTMLの後にjqueryを追加しています。
$detail .= chr(10) . '<script type="text/javascript">';
$detail .= chr(10) . '$( "#checkPage" ).bind( "pageinit",function(event){';
$detail .= chr(10) . ' $("#txtAmount").change(function(){';
$detail .= chr(10) . ' alert("INSIDE");';
$detail .= chr(10) . ' });';
$detail .= chr(10) . '});';
$detail .= chr(10) . '</script>';
return $detail;
ページに移動して金額テキストボックスに入力(およびそのまま)すると、アラートが表示されます。また、ページ(別のページにリダイレクトされている場所)のキャンセルボタンをクリックしてから、メニューのハイパーリンクから再度戻り、テキストボックスをもう一度入力(および終了)すると、アラートが表示されます。ただし、フォームを送信し、検証エラーを検出してページを再表示すると、pageinitが再度設定されません。pageinitロジックを省略しても、変更イベントは設定されなくなります。
私は何が間違っているのですか?私は私が得ることができるどんな助けにも感謝します。