Last active
          February 28, 2023 14:00 
        
      - 
      
- 
        Save rg3915/659c0a939d27e8126edffbd7a3ba600d to your computer and use it in GitHub Desktop. 
    AlpineJS child component
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no"> | |
| <link rel="shortcut icon" href="https://alpinejs.dev/favicon.png"> | |
| <title>AlpineJS</title> | |
| <!-- Bulma --> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css"> | |
| <!-- Font-awesome --> | |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> | |
| <!-- Alpine.js --> | |
| <script src="//unpkg.com/alpinejs" defer></script> | |
| </head> | |
| <body> | |
| <div | |
| class="container mt-6" | |
| x-data="{ | |
| items: [ | |
| { id: 1, title: 'One' }, | |
| { id: 2, title: 'Two' }, | |
| { id: 3, title: 'Three' } | |
| ]}" | |
| > | |
| <table class="table"> | |
| <tbody> | |
| <template | |
| x-for="item in items" | |
| :key="item.id" | |
| > | |
| <tr x-data="{ object: item }"> | |
| <td x-text="object.id"></td> | |
| <td x-text="object.title"></td> | |
| <td> | |
| <i class="fa fa-trash has-text-danger" @click="items.splice(object, 1)"></i> | |
| </td> | |
| </tr> | |
| </template> | |
| </tbody> | |
| </table> | |
| </div> | |
| </body> | |
| </html> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment