You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: jade/page-contents/toasts_content.html
+41-10Lines changed: 41 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,14 @@
4
4
5
5
<divid="introduction" class="section scrollspy">
6
6
<p>Materialize provides an easy way for you to send unobtrusive alerts to your users through toasts. These toasts are also placed and sized responsively, try it out by clicking the button below on different device sizes.</p>
7
-
<aclass="waves-effect waves-light btn" onclick="M.toast({html: 'I am a toast'})">Toast!</a>
7
+
<aclass="waves-effect waves-light btn" onclick="M.toast({text: 'I am a toast'})">Toast!</a>
8
8
<p>To do this, call the M.toast() function programmatically in JavaScript.</p>
9
9
<pre><codeclass="language-javascript">
10
-
M.toast({html: 'I am a toast!'})
10
+
M.toast({text: 'I am a toast!'})
11
11
</code></pre>
12
12
<p>One way to add this into your application is to add this as an onclick event to a button.</p>
13
13
<pre><codeclass="language-markup">
14
-
<a onclick="M.toast({html: 'I am a toast'})" class="btn">Toast!</a>
14
+
<a onclick="M.toast({text: 'I am a toast'})" class="btn">Toast!</a>
<p>You can pass in an HTML String as the first argument as well. Take a look at the example below, where we pass in text as well as a flat button. If you call an external function instead of in-line JavaScript, you will not need to escape quotation marks. </p>
146
+
<p>You can pass in an HTML String as the first argument as well. Take a look at the example below, where we pass
147
+
in text as well as a flat button. If you call an external function instead of in-line JavaScript, you will not
148
+
need to escape quotation marks. </p>
149
+
<p>
150
+
Only use a properly sanitized or otherwise trusted HTML string.
151
+
</p>
121
152
<aclass="waves-effect waves-light btn" onclick="displayCustomHTMLToast()">Toast with Action</a>
122
153
<pre><codeclass="language-javascript">
123
154
var toastHTML = '<span>I am toast content</span><button class="btn-flat toast-action">Undo</button>';
124
-
M.toast({html: toastHTML});
155
+
M.toast({unsafeHTML: toastHTML});
125
156
</code></pre>
126
157
</div>
127
158
128
159
129
160
<divid="callback" class="scrollspy section">
130
161
<h3class="header">Callback</h3>
131
162
<p>You can have the toast callback a function when it has been dismissed.</p>
132
-
<aclass="btn" onclick="M.toast({html: 'I am a toast', completeCallback: function(){alert('Your toast was dismissed')}})">Toast!</a>
163
+
<aclass="btn" onclick="M.toast({text: 'I am a toast', completeCallback: function(){alert('Your toast was dismissed')}})">Toast!</a>
133
164
<pre><codeclass="language-markup">
134
-
<a class="btn" onclick="M.toast({html: 'I am a toast', completeCallback: function(){alert('Your toast was dismissed')}})">Toast!</a>
165
+
<a class="btn" onclick="M.toast({text: 'I am a toast', completeCallback: function(){alert('Your toast was dismissed')}})">Toast!</a>
<p>We've added the ability to customize your toasts easily. You can pass in classes as an optional parameter into the toast function. We've added a rounded class for you, but you can create your own CSS classes and apply them to toasts. Checkout out our full example below.</p>
142
173
143
-
<aclass="waves-effect waves-light btn" onclick="M.toast({html: 'I am a toast!', classes: 'rounded'})">Round Toast!</a>
174
+
<aclass="waves-effect waves-light btn" onclick="M.toast({text: 'I am a toast!', classes: 'rounded'})">Round Toast!</a>
144
175
145
176
<pre><codeclass="language-javascript">
146
177
// 'rounded' is the class I'm applying to the toast
147
-
M.toast({html: 'I am a toast!', classes: 'rounded'});
178
+
M.toast({text: 'I am a toast!', classes: 'rounded'});
0 commit comments