function onDeviceReady() {
var resorts_html = '';
$.getJSON(
SA.base_url + '/resorts',
function (data) {
$.each(data.resorts, function(key, val) {
resorts_html += '<li resort_id="' + val.id + '"><a href="#">' + val.name + '</a></li>';
});
$('#resorts[data-role=page] #resort_list[data-role=listview]').html(resorts_html);
$('li').bind('tap', function() { // this is a mess. 'tap' fires off multiple times each click.
var resort_id = $(this).attr('resort_id');
debug.log('Tapped: ' + resort_id);
});
}
)
}
HTML:
<!-- Index Page -->
<div id="main" data-role="page">
<div data-role="header">
<h1>Title</h1>
</div>
<div data-role="content">
<h3>Welcome</h3>
<a href="#resorts" data-role="button">View Resorts</a>
</div>
</div>
<!-- Resorts Page -->
<div id="resorts" data-role="page">
<div data-role="header">
<h1>Resorts</h1>
</div>
<div data-role="content">
<ul id="resort_list" data-role="listview">
</ul>
</div>
</div>