Generic Modal Alert

Generic Modal Alert

This page describes how to create a generic modal window for confirmation messages etc.

function confirm(heading, question, iconDetails, cancelButtonTxt, okButtonTxt, callback) {
	var iconString = '';
	if (iconDetails != "") question = iconString + question;
	var confirmModal =
	$('

' ); confirmModal.find('#okButton').click(function (event) { callback(); confirmModal.modal('hide'); }); confirmModal.modal('show'); };

Usage:

$('#NewsItemsListHolder').on('click', '.newsItemDeleteOpener', function () {
	var heading = 'Confirm News Item Deletion';
	// use alert colours for foreground and background colour change
	//		alert-block, alert-error, alert-success and alert-info
	// use text colours for just foreground colour change
	//		muted, text-warning, text-error, text-info or text-success
	var iconDetails = ' icon-warning-sign text-success';
	var question = 'Please confirm that you wish to delete this news item. Please note that this cannot be reversed.';
	var cancelButtonTxt = 'Cancel';
	var okButtonTxt = 'Confirm';
	var confirmCallback = function () {
		//
		// stuff to do if cornfirm action is selected
		//
	};
	confirm(heading, question, iconDetails, cancelButtonTxt, okButtonTxt, confirmCallback);
});

Output

Modal Alert Box‚Äč

This page was last modified on Wednesday, 7th February 2018 at 08:58:55 by Gary Keeling. © 2019 GKWeb Design.

Categorised as: Development

GK5 Footer

and whatever