Skip to content

Wrapping An Instance

madprops edited this page Aug 9, 2017 · 8 revisions

These are some simple examples on possible ways you can make your own functions to manage a Msg instance. #2 and #3 show some ways to create instances on the fly when you need them and destroy them on close.

Simple example #1

var msg = Msg();

function show_modal(html)
{
	msg.set_or_show(html);
}

show_modal("Hello");

Simple example #2

function fadeless_modal()
{
	return Msg(
	{
		persistent: false, // This makes it destroy the html elements on close
		fade_in: false,
		fade_out: false
	});
}

fadeless_modal().show("Hello");

Simple example 3 (On The Fly)

function create_blue_modal(persistent)
{
	return Msg(
	{
		persistent: persistent,
		class: "blue"
	});
}

function show_blue_modal(html)
{
	create_blue_modal(false).show(html);
}

show_blue_modal("Hello");
Clone this wiki locally