Advertisement
Guest User

Untitled

a guest
Sep 1st, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. const Vue = require('vue');
  2. const $ = require('jquery');
  3. const VueResource = require('vue-resource');
  4. const VueTables = require('vue-tables');
  5.  
  6. Vue.use(VueTables.client, {
  7. compileTemplates: true,
  8. templates: {
  9. edit: function (row) {
  10. return "<a href=# @click='$parent.showSubRow(" + row.id + ")'>Edit</a>";
  11. },
  12. addRow: function (row) {
  13. return "<a href=# @click='$parent.addRow(" + row.id + ")'>Add</a>";
  14. },
  15. toggleRow: function (row) {
  16. return "<a href=# @click='$parent.toggleRow(" + row.id + ")'>Toggle</a>";
  17. }
  18. },
  19. texts: {
  20. filter: "Search:"
  21. },
  22. datepickerOptions: {
  23. showDropdowns: true
  24. }
  25. }, { template: require('./table-template.html') });
  26.  
  27. new Vue({
  28. el:"#app",
  29. data: {
  30. columns:['id','name','business', 'contact', 'actions'],
  31. tableData: [
  32. {id: 1, name: "John Smith", business: "Animal Fighters", contact: "address", actions: "call"},
  33. {id: 2, name: "John Smith", business: "Animal Fighters", contact: "address", actions: "call" },
  34. {id: 3, name: "John Smith", business: "Animal Fighters", contact: "address", actions: "call" },
  35. {id: 4, name: "John Smith", business: "Animal Fighters", contact: "address", actions: "call" },
  36. {id: 5, name: "John Smith", business: "Animal Fighters", contact: "address", actions: "call" }
  37. ],
  38. options: {
  39. // see the options API
  40. }
  41. },
  42. methods: {
  43. showSubRow: function (argument1) {
  44. console.log(argument1);
  45. },
  46. addRow: function (argument1) {
  47. this.tableData.push({ id: 5, name: "John Smith", business: "Animal Fighters", contact: "address", actions: "call" });
  48. },
  49. toggleRow: function (row) {
  50. let hiddenRow = document.getElementById(row + "b");
  51. hiddenRow.style.display = hiddenRow.style.display === 'none' ? '' : 'none';
  52. }
  53. }
  54. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement