Tôi đang cố gắng lấy div có hộp thoại 'kiểu dữ liệu' để hiển thị trong JQuery Mobile, được kích hoạt bởi sự kiện Javascript. Nhấp vào nút trong ví dụ bên dưới là hoàn toàn kích hoạt sự kiện.Không thể Nhận Hộp thoại để hiển thị theo chương trình trong JQuery Mobile
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//$.mobile.changePage('#addCatForm');
$('#createEvent').click (function() {
console.log('Prove event fired');
$.mobile.changePage('#addCatForm', {
transition: 'pop',
changeHash: false,
role: 'dialog'
});
});
});
</script>
</head>
<body>
<div data-role="page" id="mainPage">
<button id="createEvent">Create Event</button>
<div data-role="dialog" id="addCatForm" data-theme="c">
<p>here is some text</p>
<div data-role="content">
<input type="text" id="catText" data-theme="c"/>
<input data-role="button" data-mini="true" data-theme="b" data-inline="true" type="submit" id="addCat" value="Add Category">
<button data-role="button" data-mini="true" data-theme="c" data-inline="true" id="canCat">Cancel</button>
</div>
</div>
</div>
</body>
Đầu ra console.log được kích hoạt chính xác, nhưng tôi không thể làm gì để hiển thị hộp thoại.
Bất kỳ trợ giúp nào được đánh giá cao.
Cảm ơn bạn,
Đặt div 'dialog' bên ngoài 'data-role = page'. chỉ các quảng cáo mới có thể được chèn vào bên trong 'data-role = page'. Hãy coi nó là một 'trang' nhưng thay vào đó bằng 'data-role = dialog'. – Omar