Skip to content

This package allows you to easily use a Meteor template within a bootbox dialog.

License

Notifications You must be signed in to change notification settings

HelloLudger/meteor-mbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

helloludger:mbox

This package allows you to easily use a Meteor template within a bootbox.js dialog.

How To Use

Dependencies

You need Bootstrap and bootbox.js for this package. I use

but since there are many ways to include Bootstrap in your project, I only made mizzao:bootboxjs a weak dependency.

Basics

If the first parameter isn't an object if you use a normale message instead of an Meteor Template, mbox will simply call bootbox with the given parameters.

You can use all variants bootbox.js offers for modals. Simply call mbox.alert( ... ) instead of bootbox.alert( ... ). For a detailed list of modal variants and how to include different buttons, etc., check out bootbox.js's documentation.

Including A Template

mbox.alert({
	message: Template.mboxNoData, 
});

This will open an alert modal and render the template "mboxNoData" in its body. You have to provide the template in an object as the value of the message key. The object is the only allowed parameter for the mbox.*something* function call.

Including A Template With Data

mbox.alert({
	message: Template.mboxWithData, 
	data: { somevalue: "Hello world!" }
});

This will open an alert modal and render the template "mboxWithData" in its body. Within the template, a simple {{somevalue}} will render the data, in this case Hello World!.

You have to provide the template in an object as the value of the message key. The object is the only allowed parameter for the mbox.*something* function call.

If you provide the data in this way, it will not be ractive.

Including A Template With Reactive Data

mbox.alert({
	message: Template.mboxWihReactiveData, 
	**data: function() {
		return {
			reactiveData: Session.get("myReactiveData"),
			otherData: SomeCollection.findOne().name
		}**
	}
});

This will open an alert modal and render the template "mboxWihReactiveData" in its body. Within the template, a simple {{reactiveData}} will render the data.

You have to provide the template in an object as the value of the message key. The object is the only allowed parameter for the mbox.*something* function call.

Only if you wrap your data in a function it will be reactive.

Examples

Check out the example page under http://mbox.meteor.com.

License

Published under MIT License.

About

This package allows you to easily use a Meteor template within a bootbox dialog.

Resources

License

Stars

Watchers

Forks

Packages

No packages published