@@ -12,7 +12,7 @@ var mainView = myApp.addView('.view-main', {
1212} ) ;
1313
1414// Handle Cordova Device Ready Event
15- $$ ( document ) . on ( 'deviceready' , function ( ) {
15+ $$ ( document ) . on ( 'deviceready' , function ( ) {
1616 console . log ( "Device is ready!" ) ;
1717} ) ;
1818
@@ -22,30 +22,56 @@ $$(document).on('deviceready', function() {
2222// Option 1. Using page callback for page (for "about" page in this case) (recommended way):
2323myApp . onPageInit ( 'about' , function ( page ) {
2424 // Do something here for "about" page
25-
25+ myApp . alert ( 'Here comes About page' ) ;
2626} )
2727
2828//Messages Page
2929myApp . onPageInit ( 'messages' , function ( page ) {
3030 messagesMain ( ) ;
31+ } )
3132
33+ myApp . onPageInit ( 'post' , function ( page ) {
34+ console . log ( page . query ) ;
35+ /*
36+ 1. Do AJAX call to get post based on postID
37+ 2. Generate post data!
38+ */
3239
3340} )
3441
42+ myApp . onPageInit ( 'postList' , function ( page ) {
43+ console . log ( 'posted!' ) ;
3544
36- // Option 2. Using one 'pageInit' event handler for all pages:
37- $$ ( document ) . on ( 'pageInit' , function ( e ) {
38- // Get page data from event data
39- var page = e . detail . page ;
45+ /*
46+ 1. Do AJAX call
47+ 2. Put data into Array
48+ 3. Set array
49+ */
50+ const posts = [
51+ /*
52+ {
53+ title: 'Need people to show shovel for me tomorrow!',
54+ text: 'House is not too large, so should not be an issue!',
55+ price: '5',
56+ postalCode: '5'
57+
58+ }*/
59+ ] ;
4060
41- if ( page . name === 'about' ) {
42- // Following code will be executed for page with data-page attribute equal to "about"
43- myApp . alert ( 'Here comes About page' ) ;
61+ for ( var i = 0 ; i < 50 ; i ++ ) {
62+ posts . push ( {
63+ item : i
64+ } ) ;
4465 }
45- } )
4666
47- // Option 2. Using live 'pageInit' event handlers for each page
48- $$ ( document ) . on ( 'pageInit' , '.page[data-page="about"]' , function ( e ) {
49- // Following code will be executed for page with data-page attribute equal to "about"
50- myApp . alert ( 'Here comes About page' ) ;
67+ const myList = myApp . virtualList ( '.list-block.virtual-list' , {
68+ items : posts ,
69+ template :
70+ '<li>' +
71+ '<a href="post.html?postID={{item}}" class="item-link item-content">' +
72+ '<div>{{item}}</div>' +
73+ '</a>' +
74+ '</div>' +
75+ '</li>'
76+ } ) ;
5177} )
0 commit comments