juricin
Posts: 0
Joined: Tue Jan 13, 2015 5:09 am

invoke service and run javascript on page show

Hi, question.

On page show I am invoking a service that displays an amount in cents ie 1000 cents.

I also have an event on page show that runs the following javascript to change the 1000 cents into $10

$('document').ready(function(){
$('[name="amount"]').each(function(){
var v = $(this).text();
try {
v = parseInt(v, 10);
v = v / 100;
v = '$' + v;

$(this).text(v);
} catch(ex){

}

});
});

Although it works when I run the javascript in console its not working on page show.

Im thinking there is a time delay on the invoke service to show the amount (1000) and the javascript runs before that. I could put a time delay on the javascript but I dont want the users to see 1000 and then flick to $10

Any suggestions?

Thanks, Ante

Patrick Kelly
Posts: 0
Joined: Wed Nov 20, 2013 6:00 am

invoke service and run javascript on page show

I had this same problem. Instead of running the Javascript on "Page Show" or "Load", try running the script as a part of invoking the service, once it is complete:

Image

juricin
Posts: 0
Joined: Tue Jan 13, 2015 5:09 am

invoke service and run javascript on page show

Simple. Legend!

Return to “Issues”