replacement of

//$(document).ready(function(){
 with
  $(document).on("pageinit","#page2", function() {