incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Nusinov (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CB-491) cordova-1.6.0 + jquery/zepto $(document).bind("deviceready") does not work
Date Thu, 14 Jun 2012 13:09:42 GMT

    [ https://issues.apache.org/jira/browse/CB-491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295010#comment-13295010
] 

Craig Nusinov edited comment on CB-491 at 6/14/12 1:08 PM:
-----------------------------------------------------------

Hi, this is my first post and I was kindly referred by Shazron.  I upgraded from PG 1.2.0
to Cordova 1.7.0 and having all kinds of issues.  I can't seem to find a solution, but first
things first - I can not even get a simple date.js file to execute in my index.html file.
 Here is what I am doing, I know I am probably missing something pretty simple, maybe someone
can point me in the correct direction.  Thank you!  Using Xcode 4.3.2 to compile.

index.html:


<!DOCTYPE html>
<html>
  <head>
  <title></title>
  
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,
user-scalable=no;" />
	<meta charset="utf-8">


	<!-- iPad/iPhone specific css below, add after your main css >
	<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css"
type="text/css" />		
	<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css"
type="text/css" />		
	-->
	<!-- If your application is targeting iOS BEFORE 4.0 you MUST put json2.js from http://www.JSON.org/json2.js
into your www directory and include it here -->
	<script type="text/javascript" charset="utf-8" src="cordova-1.8.0.js"></script>
      <script type="text/javascript" charset="utf-8" src="jquery-1.7.2.min.js"></script>
      <script type="text/javascript" charset="utf-8" src="today.js"></script>
     

      
      <script type="text/javascript">

	// If you want to prevent dragging, uncomment this section
	/*
	function preventBehavior(e) 
	{ 
      e.preventDefault(); 
    };
	document.addEventListener("touchmove", preventBehavior, false);
	*/
	
	/* If you are supporting your own protocol, the var invokeString will contain any arguments
to the app launch.
	see http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
	for more details -jm */
	/*
	function handleOpenURL(url)
	{
		// TODO: do something with the url passed in.
	}
	*/
	
	function onBodyLoad()
	{		
		document.addEventListener("deviceready", onDeviceReady, false);
	}
	
	/* When this function is called, Cordova has been initialized and is ready to roll */
	/* If you are supporting your own protocol, the var invokeString will contain any arguments
to the app launch.
	see http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
	for more details -jm */
	function onDeviceReady()
	{
		// do your thing!
		navigator.notification.alert("Cordova is working")
	}
    
    </script>
    
     
  </head>
   
  <body onload="onBodyLoad()">
     
     <div id="output"></div><BR><BR>
     

	<h1>Hey, it's Cordova!</h1>
	<p>Don't know how to get started? Check out our <em><a target="_blank" href="http://docs.phonegap.com/en/edge/guide_getting-started_ios_index.md.html#Getting%20Started%20with%20iOS">Getting
Started Guide</a></em>
	<br />
	<ol>
		<li>Check your console log for any white-list rejection errors.</li>
		<li>Add your allowed <strong>hosts</strong> in Cordova.plist/ExternalHosts
(wildcards OK, don't enter the URL scheme)</li>
	</ol>
  </body>
</html>


today.js - javascript file:


// today.js
// This script indicates the current date and time.

// Call this function when the page has loaded:
function init() {
    
    // Want to be strict:
    'use strict';

    // Create a Date object:
    var today = new Date();

    // Create a custom message:
    var message = 'Today is ' + today.toLocaleDateString();
    
    
    // Get a reference to the paragraph:
    var output = document.getElementById('output');
    
    // Update the innerText or textContent property of the paragraph:
	if (output.textContent !== undefined) {
		output.textContent = message;
	} else {
		output.innerText = message;
	}
    
} // End of init() function.

window.onload = init;

                
      was (Author: applenoose):
    Hi, this is my first post and I was kindly referred by Shazron.  I upgraded from PG 1.2.0
to Cordova 1.7.0 and having all kinds of issues.  I can't seem to find a solution, but first
things first - I can not even get a simple date.js file to execute in my index.html file.
 Here is what I am doing, I know I am probably missing something pretty simple, maybe someone
can point me in the correct direction.  Thank you!

index.html:


<!DOCTYPE html>
<html>
  <head>
  <title></title>
  
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,
user-scalable=no;" />
	<meta charset="utf-8">


	<!-- iPad/iPhone specific css below, add after your main css >
	<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css"
type="text/css" />		
	<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css"
type="text/css" />		
	-->
	<!-- If your application is targeting iOS BEFORE 4.0 you MUST put json2.js from http://www.JSON.org/json2.js
into your www directory and include it here -->
	<script type="text/javascript" charset="utf-8" src="cordova-1.8.0.js"></script>
      <script type="text/javascript" charset="utf-8" src="jquery-1.7.2.min.js"></script>
      <script type="text/javascript" charset="utf-8" src="today.js"></script>
     

      
      <script type="text/javascript">

	// If you want to prevent dragging, uncomment this section
	/*
	function preventBehavior(e) 
	{ 
      e.preventDefault(); 
    };
	document.addEventListener("touchmove", preventBehavior, false);
	*/
	
	/* If you are supporting your own protocol, the var invokeString will contain any arguments
to the app launch.
	see http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
	for more details -jm */
	/*
	function handleOpenURL(url)
	{
		// TODO: do something with the url passed in.
	}
	*/
	
	function onBodyLoad()
	{		
		document.addEventListener("deviceready", onDeviceReady, false);
	}
	
	/* When this function is called, Cordova has been initialized and is ready to roll */
	/* If you are supporting your own protocol, the var invokeString will contain any arguments
to the app launch.
	see http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
	for more details -jm */
	function onDeviceReady()
	{
		// do your thing!
		navigator.notification.alert("Cordova is working")
	}
    
    </script>
    
     
  </head>
   
  <body onload="onBodyLoad()">
     
     <div id="output"></div><BR><BR>
     

	<h1>Hey, it's Cordova!</h1>
	<p>Don't know how to get started? Check out our <em><a target="_blank" href="http://docs.phonegap.com/en/edge/guide_getting-started_ios_index.md.html#Getting%20Started%20with%20iOS">Getting
Started Guide</a></em>
	<br />
	<ol>
		<li>Check your console log for any white-list rejection errors.</li>
		<li>Add your allowed <strong>hosts</strong> in Cordova.plist/ExternalHosts
(wildcards OK, don't enter the URL scheme)</li>
	</ol>
  </body>
</html>


today.js - javascript file:


// today.js
// This script indicates the current date and time.

// Call this function when the page has loaded:
function init() {
    
    // Want to be strict:
    'use strict';

    // Create a Date object:
    var today = new Date();

    // Create a custom message:
    var message = 'Today is ' + today.toLocaleDateString();
    
    
    // Get a reference to the paragraph:
    var output = document.getElementById('output');
    
    // Update the innerText or textContent property of the paragraph:
	if (output.textContent !== undefined) {
		output.textContent = message;
	} else {
		output.innerText = message;
	}
    
} // End of init() function.

window.onload = init;

                  
> cordova-1.6.0 + jquery/zepto $(document).bind("deviceready") does not work
> --------------------------------------------------------------------------
>
>                 Key: CB-491
>                 URL: https://issues.apache.org/jira/browse/CB-491
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS
>    Affects Versions: 1.6.0
>         Environment: Tested on iOS 5.1
>            Reporter: Moisés Gramary
>            Assignee: Filip Maj
>            Priority: Minor
>              Labels: javascript, patch
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> With Phonegap1.4 or 1.5, I have been OK with the code below, but now I stuck.
> Anyone has an idea? Thanks.
> <html>
> <head>
>     <meta name="viewport" content="width=device-width,
> initial-scale=1.0, maximum-scale=1.0, user-scalable=no;"/>
>     <meta charset="utf-8">
>     <script type="text/javascript" charset="utf-8"
> src="js/cordova-1.6.0.js"></script>
>     <script type="text/javascript" src="js/jquery.min.js"></script>
>     <script type="text/javascript">
>         $(document).ready(function()
>         {
>             alert("this Alert fires OK");
>             $(document).bind("deviceready", function()
>             {
>                 alert("Got the Error and this Alert Never fires");
>             });
>         });
>     </script>
> </head>
> <body>
> <p id="deviceProperties" style="font-size: 20px"></p>
> </body>
> </html>
> (by KenOKABE on https://groups.google.com/forum/?hl=en?hl%3Den&fromgroups#!topic/phonegap/TImcr9kzlq0)
> Possible solution-->
> Hello, I had the same problem with the upgrade from 1.5 to 1.6...
> After a long day I found that that deviceready event begins a little "freak", try changing:
>     $(document).bind("deviceready", function()
>     {
>         //code
>     });
> by:
>     document.addEventListener("deviceready", function()
>     {
>         //code
>     }, false);
> It worked for me, even so, the most weird thing is that other events like touchmove or
orientationchange still works with $( document ).bind; even $( document ).ready function works....
> Appears to fail only with deviceready PG/CV event....
> (by Moisés Gramary Barbosa on same thread)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message