ConfirmDialogBox turned into pormpt dialog box

In this sample, an ConfirmDialogBox is turned into prompt dialog box.

To do this, we need a simple form with label and input. Callback function on event of ok button is requiered but not on click event of cancel button. The callback function is an anonymous function.

NB: in parameters, the name of callback function is given without brackets. Callback function is optionnal.

Source Code


$(document).ready(function() {
	//To use advanced settings, you must define var.
	var msg = new AntMessageBox();		
	
	function callBack(value) {
		var welcome_txt = "Welcom to my website "+ value +" !!";
		$("#welcome").removeClass("hidden").html(welcome_txt);	//set div display to visible				
	}
	
	$("#open").click(function () {							
		msg.initDialogBox("Prompt Dialog Box", "#promptHiddenForm");
		msg.ConfirmDialogBox(null, function() { callBack($("#answer").val())}); //I use null as content parameter to use directly inner html of promptHiddenForm div
	});				
});