Commit 3dc7844

mo <mo.khan@gmail.com>
2018-12-09 05:41:14
connect close button to controller.
1 parent 71a4eb8
Changed files (2)
app
javascript
views
application
app/javascript/controllers/notification_controller.js
@@ -0,0 +1,7 @@
+import ApplicationController from './application_controller';
+
+export default class extends ApplicationController {
+  close() {
+    this.element.remove();
+  }
+}
app/views/application/_flash.html.erb
@@ -1,8 +1,8 @@
 <div class="container">
   <% flash.each do |type, message| %>
     <% Array(message).each do |value| %>
-      <div class="notification <%= alert_class_for(type) %>">
-        <button class="delete"></button>
+      <div data-controller="notification" class="notification <%= alert_class_for(type) %>">
+        <button data-action="click->notification#close" class="delete"></button>
         <%= value %>
       </div>
     <% end %>