Guest User

Table Data

a guest
Jan 9th, 2016
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var tableData = {
  2.     data: [
  3.         {
  4.             'name': 'Gary Finch',
  5.             'jobtitle': 'Front End Technical Lead',
  6.             'website': 'http://website.com'
  7.         },
  8.         {
  9.             'name': 'Bob McFray',
  10.             'jobtitle': 'Photographer',
  11.             'website': 'http://goo.gle'
  12.         },
  13.         {
  14.             'name': "Jenny O'Sullivan",
  15.             'jobtitle': 'LEGO Geek',
  16.             'website': 'http://stackoverflow.com'
  17.         }]
  18. }
  19.  
  20. var app = app || {};
  21.  
  22. app.table = (function () {
  23.     function Table(selector, data) {
  24.         this.selector = selector;
  25.         this.data = data;
  26.     }
  27.        
  28.         Table.prototype.buildTable = function () {
  29.             var tableRow;
  30.            
  31.             $.get('templates/tableDataTemplate.html', function (template) {
  32.             tableData.data.forEach(function (obj) {
  33.                 tableRow = Mustache.render(template, obj);
  34.                 $(this.selector).append(tableRow);
  35.             })
  36.         })
  37.         }    
  38.  
  39.     return {
  40.         load: function (selector, data) {
  41.             return new Table(selector, data);
  42.         }
  43.     }
  44. })();
  45.  
  46. var table = app.table.load('tbody', tableData);
  47.  
  48. table.buildTable();
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×