Version event doesn't fire.

<!DOCTYPE html>

From reading the help file, it seems the following should work, but it does not.

rho 1.0.2.3 on es400.

Any thoughts on what is wrong?

Dan

---

<html>

<head>

<title></title>

<META http-equiv="Application" content="VersionEvent:url('Javascript:doVersion(%json);')">

<script type="text/javascript">

    function doVersion(jsonObject){

        alert("This never fires");

        alert(jsonObject.ProductVersion);

    }

</script>

</head>

 

<body onload="alert('alert works');">

<p>Hello world</p>

</body>

</html>

Louie Avila
I looked at the documentation

I looked at the documentation.  Seems like Product Version passes a char value.   So your

url('Javascript:doVersion(%json);

may need to look like

url('Javascript:doVersion('%json');

Change made: added quotes

Help shows: <META HTTP-Equiv="Application" content="VersionEvent:url('Javascript:doVersion('%1', %3);')">

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Dan McCabe
Louie,Thx. Good guess, but

Louie,

Thx. Good guess, but no cigar.

Once I added the call to getVersion, the event fires without the quotes,

but not with the quotes.

Now though, the ProductVersion comes back as undefined. Errr.

Dan

On Thu, Jan 26, 2012 at 5:40 PM, Louie Avila <

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Louie Avila
By the way, check chrome or

By the way, check chrome or safari inspector.  I saw error there.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
You haven't called the

You haven't called the getVersion method

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Dan McCabe
Darryn,It would be great if

Darryn,

It would be great if you guys had a known good, fully copy and pasteable sample program demonstrating each function in the help file or online.

The gold standard for this right now are these guys: https://stripe.com/docs/tutorials/forms

It literally takes minutes to get their stuff working.. no reading, parsing, and interpreting tons of prose... just copy, paste, and go.

Even better would be live demos hosted on a var accessible moto site... that solves all the mis-spellings in the docs issue.

For instance, in the rho help, you have the following:

The following example code shows how to access the different data structures in the JSON object:

Function doVersion(jsonObject) { var theOutput = "Product Version: " + jsonObject.ProductVersion + "<P>"; theOutput 

That doesn't work because "Function" with a capital F doesn't work.

Anyway, I still can't get this working.  Now I get "Product version: undefined"

Here is the code, can you tell me what is wrong with it?

<!DOCTYPE html>

<html>

<head>

<title></title>

<META http-equiv="Application" content="VersionEvent:url('Javascript:doVersion(%json);')">

<script type="text/javascript">

    function doVersion(jsonObject)

    {

        alert('doVersion fired');

        var theOutput = "Product Version: " + jsonObject.ProductVersion;

        alert(theOutput);

    }

</script>

</head>

 

<body onload="application.getVersion();">

<p>Hello world</p>

</body>

</html>

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Product version is undefined

Product version is undefined because you need to use a small 'p'.

There is an example in the help file for version event and you can click the 'Copy example to clipboard' text to copy it... it's just above the 'Remarks' section on the Application page.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Dan McCabe
Darryn,Thanks.. that did it

Darryn,

Thanks.. that did it.

FYI: There are at least 4 places in Getting Started.. Retrieval Events

where ProductVersion is spelled with a capital P.

That is where I was copying from.

Dan

On Fri, Jan 27, 2012 at 10:12 AM, Darryn Campbell <

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Doh!!  I Wish I would have

Doh!!  I Wish I would have read that half an hour ago before I built the latest version, thanks, I'll fix that during our next iteration.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robin West
Hi Darryn,Yes, the METATAG

Hi Darryn,

Yes, the METATAG works for

<META HTTP-EQUIV="Application" content="VersionEvent:url('javascript:fnVerJSON(%json);')">

However; when declaring the event handler via JavaScript, "undefined" still appears to be a problem.


application.versionEvent =

"url('JavaScript:fnVersionEventHandler(%json);')"

;

Please advise.

Thanks,

Tim

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Tim, please can you post

Hi Tim, please can you post more of your code showing the problem?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Timothy Murphy
Given my event handler

Given my event handler definition below, if I declare this handler within an application metatag, the handler fires as expected, and the log line is written.

function fnVersionEventHandler(jsonObj){

generic.Log('ProdVer:'+jsonObj.productVersion,1);

}

function deviceInit(){

application.getVersion();

application.versionEvent = "url('JavaScript:fnVersionEventHandler(%json);')";

}

However; when removing the metatag, and declaring the versionEvent handler in deviceInit(), the handler never fires??

Thanks,

Tim

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robert Galvin
TimTry changing your

Tim

Try changing your javascript to be:

application.versionEvent = "fnVersionEventHandler(%json)";

http://docs.rhomobile.com/rhoelements/RetrievalEvents

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Timothy Murphy
Rob,Good thought, but didn’t

Rob,

Good thought, but didn’t help

Thanks,

Tim

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Nrusingha Chara...
Hello Tim,Please try as

Hello Tim,

Please try as below

application.versionEvent = "fnVersionEventHandler(%json);";

Thanks

Patro

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Timothy Murphy
Already did, but no help

Already did, but no help.

Thanks,

Tim

email: Timothy.Murphy@motorolasolutions.com

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robin West
The function deviceInit()

The function deviceInit() needs to be like below

function deviceInit()

{

application.versionEvent="fnVersionEventHandler(%json);";

application.getVersion();

}

Need to register the event first then call getVersion method

This should fix the issue.

Thanks

Patro

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Darryn Campbell
Doh…That was it!! I

Doh…That was it!! I accidentally reversed the lines, on a bad cut/paste job, and forgot it was like that. Thank you all very much!

Tim

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments