Why does alert handler on Kony activate when YesLabel or NoLabel was clicked?

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

Hi, I have sample code for alert confirmation.

var alertBasic = {message:"Are you sure to quit?",alertType:constants.ALERT_TYPE_CONFIRMATION,yesLabel:"yes",noLabel:"no",alertHandler:alertHandlerCallBck};
var alertPSP = {};
var alert = new kony.ui.Alert(alertBasic, alertPSP);

function alertHandlerCallBck(alert)
{
	kony.application.exit();
}</code><p>When I clicked Yes button or No button, why is alertHandlerCallBck called? I want alertHandlerCallBck is called only when I clicked Yes Label.</p><p>I hope Kony senior can help me.</p><p>Sorry if my English is bad.</p><p>Thank you !  </p>

Hi @Owen Hvwdvcwe​ ,

You need to check the parameter passing(whether true or false) to the alert handler function.

To match your case, you can write the alert handler function like

function alertHandlerCallBck(alert)

{

if(alert)

kony.application.exit();

}

Onclick of Yes sends the param as true and Onclick of No sends the param as false

Hi @Tim Gwvhvm​ ,

Thank you so much for your help! It's work!