Page 1 of 1

problem with alert

Posted: Thu Mar 06, 2014 5:13 pm
by Michael4771079

Hi,
I came across this code for adding an alert from this link, http://stackoverflow.com/questions/94...
I cant get this to work, I running the code on click

can you see anything wrong, I need to have alerts without the pagename on the alert title

thx

codefunction showMessage(message, callback, title, buttonName){

Code: Select all

 title = title || "default title&quot 
 buttonName = buttonName || 'OK'; 

 if(navigator.notification && navigator.notification.alert){ 

     navigator.notification.alert( 
         message,    // message 
         callback,   // callback 
         title,      // title 
         buttonName  // buttonName 
     ); 

 }else{ 

     alert(message); 
     callback(); 
 } 

}/code


problem with alert

Posted: Thu Mar 06, 2014 6:40 pm
by Maryna Brodina

Hello!
Your code works for us.
Could you clarify what device/OS version you use to test? Are title and button caption set? Could you post the screenshot?


problem with alert

Posted: Thu Mar 06, 2014 7:07 pm
by Michael4771079

Hi Maryna,
I have misunderstood the implementation of this code, I have just copied it and used it on a click event, I added my title and message but its wrong.
I thought the settings were in the code
this is the code and it will explain of how I thought it could be used

thx

codefunction showMessage(message, callback, title, buttonName){

Code: Select all

 title = title || "Cart&quot 
 buttonName = buttonName || 'OK'; 

 if(navigator.notification && navigator.notification.alert){ 

     navigator.notification.alert( 
         message,    // message 
         callback,   // callback 
         title,      // title 
         buttonName  // buttonName 
     ); 

 }else{ 

     alert(Added To Your Order); 
     callback(); 
 } 

}/code


problem with alert

Posted: Thu Mar 06, 2014 7:11 pm
by Michael4771079

sorry Maryna, forgot to say,
testing in browser as this code is supposed to work for web and phonegap apps


problem with alert

Posted: Thu Mar 06, 2014 7:58 pm
by Maryna Brodina

Create JS asset with your code and on click event run this code preshowMessage("message text", function(){}, "title", "buttonName");/prePlease note in browser there will be ordinary alert.


problem with alert

Posted: Thu Mar 06, 2014 8:16 pm
by Michael4771079

Hi Maryna,
I dine that but I got an error in console, here is the s/s of the js and the error

Image

Image


problem with alert

Posted: Thu Mar 06, 2014 8:32 pm
by Maryna Brodina

Replace prealert(Added To Your Order);/pre with prealert("Added To Your Order");/pre


problem with alert

Posted: Thu Mar 06, 2014 8:50 pm
by Michael4771079

Great Maryna,
thx very much, I am very grateful as I am aware js is not within the support remit,
best support there is!

cheers