Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.73 KB | None | 0 0
  1. <div class="widget-content" id="websites-table">
  2.     <table v-if="rows.length" class="table table-hover table-bordered">
  3.         <thead>
  4.             <tr>
  5.                 <th>Name</th>
  6.                 <th>Country</th>
  7.                 <th class="col-md-1">Actions</th>
  8.             </tr>
  9.         </thead>
  10.         <tbody>
  11.             <tr
  12.                 is="website-row"
  13.                 v-for="(website, index) in rows"
  14.                 v-bind:item="website"
  15.             ></tr>
  16.         </tbody>
  17.     </table>
  18.     <div class="text-right" v-bind:class="{ 'text-right': rows.length, 'text-center' : !rows.length  }"><button data-toggle="modal" data-target="#createWebsite" class="btn btn-success">Add new</button></div>
  19. </div>
  20.  
  21. <script>
  22.     var countries = {"1":"United States","2":"Ukraine","3":"Singapore"};
  23.     Vue.component('website-row', {
  24.     template: '\
  25.         <tr>\
  26.         <td>{{ item.name }}</td>\
  27.         <td>{{ country }}</td>\
  28.         <td class="text-center"><a v-bind="{ href: \'/websites/\'+item.id}"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a></td>\
  29.         </tr>\
  30.     ',
  31.     props: ['item'],
  32.     computed: {
  33.         country: function () {
  34.             return countries[this.item["country_id"]];
  35.         }
  36.     }
  37.     })
  38.     var websites = new Vue({
  39.         el: '#websites-table',
  40.             data: {
  41.                 rows: [{"id":1,"country_id":2,"service_id":1,"url":"","name":"\u0434\u0435\u0448\u0435\u0432\u0456 \u043a\u0443\u043f\u043e\u043d\u0438","created_at":"2016-11-15 09:36:47","updated_at":"2016-11-15 09:36:47"},{"id":2,"country_id":1,"service_id":1,"url":"","name":"Groupon","created_at":"2016-11-15 09:36:47","updated_at":"2016-11-15 09:36:47"},{"id":3,"country_id":3,"service_id":1,"url":"","name":"Deals SG","created_at":"2016-11-15 09:36:47","updated_at":"2016-11-15 09:36:47"},{"id":8,"country_id":2,"service_id":1,"url":"","name":"Test","created_at":"2017-01-31 16:59:00","updated_at":"2017-01-31 16:59:00"}]
  42.             }
  43.         });
  44. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement