I think I'm confused on how to trigger a modal from the Materialize Modal package. Materialize Modal I've got the package loaded and I'd like to use one of the pre-baked modals.
JS:
MaterializeModal.form({
title: "Enter some Data!",
bodyTemplate: "my-form",
callback: function(error, response) {
if (response.submit) {
// Iterate over form results & display.
for (var field in response.form) {
Materialize.toast(field + ": " + response.form[field], 5000, "green");
}
} else {
Materialize.toast("Cancelled by user!", 5000, "red");
}
}
});
MaterializeModal.display({
bodyTemplate: "my-form"
});
How would the modal be triggered from the button click? Apologies for the dumb question.
解决方案
As per the docs: Specify the Modal ID in button data-target, add the class modal-trigger to the button and register the trigger. See the docs at http://materializecss.com/modals.html
There are some caveats though: modals and dropdowns do not work in the latest version of Materialize on Meteor because Meteor uses a crazy old outdated version of jQuery (it seem impossible to change Meteor's jquery version without branching and repackaging your own Meteor distro) and Materialize relies on newer jquery functionality. I worked around this by using an older version of Materialize, specifically poetic:materialize-scss@1.97.1 (SASS version of Materialize).