2
JQM 및 http://dl.dropbox.com/u/49735179/dialog-data-transfer.html을 기반으로 모바일 웹 사이트를 만들고 있습니다.jquery 모바일 데이터 섹션 간 전송
"dialogPage"섹션의 검색 결과 중 하나에서 제출 버튼을 클릭하면 zip1, zip2, addr 양식의 "mainPage"섹션에 표시되어야합니다.
그러나 zip_code1, zip_code2, addr 의 양식 값은 "mainPage"섹션으로 전송되지 않습니다.
이 스크립트의 문제점은 무엇입니까?
전체 스크립트 + html입니다.
<!DOCTYPE html>
<html>
<head>
<title>Test Dialog</title>
<meta charset="utf-8" />
<meta name="viewport" content="height=device-height,width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
</head>
<body>
<script>
$(document).ready(function() {
$('form').submit(function(){
var inputVal1 = $('input[name=zip_code1]').val();
var inputVal2 = $('input[name=zip_code1]').val();
var inputVal3 = $('input[name=addr]').val();
$("#mainPage").data("inputVal1", inputVal1);
$("#mainPage").data("inputVal2", inputVal2);
$("#mainPage").data("inputVal3", inputVal3);
})
});
$('#mainPage').live('pageshow', function(){
var inputVal1 = $(this).data('inputVal1') ? $(this).data('inputVal1') : "<? $defaultValue1 ?>";
var inputVal2 = $(this).data('inputVal2') ? $(this).data('inputVal2') : "<? $defaultValue2 ?>";
var inputVal3 = $(this).data('inputVal3') ? $(this).data('inputVal3') : "<? $defaultValue3 ?>";
$('div input[name=zip1]').val(inputVal1);
$('div input[name=zip2]').val(inputVal2);
$('div input[name=addr]').val(inputVal3);
});
</script>
<section id="mainPage" data-role="page">
<header data-role="header"><h1>Header</h1></header>
<div data-role="content">
<div>
<input type="text" name="zip1" value="">-<input type="text" name="zip2" value="">
<input type="text" name="addr" value="">
</div>
<a href="#dialogPage" data-role="button" data-transition="pop">Open Dialog</a>
</div>
<footer data-role="footer"><h1>Footer</h1></footer>
</section>
<!-- ## DIALOGS ## -->
<section id="dialogPage" data-role="dialog" data-theme="d">
<header data-role="header"><h1>Header</h1></header>
<div data-role="content">
<h3>Input Dialog</h3>
<INPUT type="text" autocomplete="off" value="" id="k"><input type="submit" value="search" onClick="kin()" data-role="button">
<DIV id="serverMsg"></DIV>
<form>
<input type=hidden name=zip_code1 value='code1'>
<input type=hidden name=zip_code2 value='code2'>
<input type=hidden name=addr value='address1'>
<table><tr>
<td width=50>code1 - code2</td>
<td>address1</td>
</tr></table>
<input type="submit" value='address1' />
</form>
<form>
<input type=hidden name=zip_code1 value='code4'>
<input type=hidden name=zip_code2 value='code5'>
<input type=hidden name=addr value='address2'>
<table><tr>
<td width=50>code4 - code5</td>
<td>address2</td>
</tr></table>
<input type="submit" value='address2' />
</form>
<form>
<input type=hidden name=zip_code1 value='code6'>
<input type=hidden name=zip_code2 value='code7'>
<input type=hidden name=addr value='address2'>
<table><tr>
<td width=50>code6 - code7</td>
<td>address3</td>
</tr></table>
<input type="submit" value='address3' />
</form>
</div>
</div>
<footer data-role="footer"></footer>
</section>
</body>
</html>
감사합니다. $ ("# mainPage")로 변경되었습니다. attr ("data-inputVal1", inputVal1); $ ("# mainPage"). attr ("data-inputVal2", inputVal2); $ ("# mainPage"). attr ("data-inputVal3", inputVal3); 하지만 여전히 섹션 "dialogPage"에서 valuse를 반환하지 않았습니다. "dialogPage"에 몇 가지 문제가 있다고 생각합니다. –
@undefined, http://stackoverflow.com/questions/10969074/how-to-have-such-a-background-flash-animation-on-mousehover-using-jquery를 살펴볼 수 있습니까? 다른 주제에 대한 jquery 질문입니다. 그러한 의견이 SE에서 허용되는지 여부를 모르겠습니다. –
@paulycho 환영합니다. 한 페이지에 3 가지 양식 요소가 있습니다. 하나의 양식으로 시험해보십시오. – undefined