Sha256: 0894b142b61b0dbf8b18a13fc8323211e2e3b077812df3b4c9f1f5f9c37ee655

Contents?: true

Size: 1.51 KB

Versions: 20

Compression:

Stored size: 1.51 KB

Contents

// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

var Book = Backbone.Model.extend({
});

var BooksCollection = Tableling.Collection.extend({
  url: '/books/page'
});

var NoBookRow = Backbone.Marionette.ItemView.extend({
  tagName: 'tr',
  className: 'empty',
  template: 'booksTableEmptyRow'
});

var BookRow = Backbone.Marionette.ItemView.extend({

  tagName: 'tr',
  template: 'booksTableRow',

  ui : {
    title: '.title',
    author: '.author'
  },

  onRender : function() {
    this.ui.title.text(this.model.get('title'));
    this.ui.author.text(this.model.get('author'));
  }
});

var BooksTableView = Tableling.Bootstrap.TableView.extend({

  itemView: BookRow,
  emptyView: NoBookRow,
  itemViewContainer: 'tbody',

  initialize : function(options) {
    Tableling.Bootstrap.TableView.prototype.initialize.call(this, options);
    this.on('composite:rendered', this.clearLoading, this);
  },

  clearLoading : function() {
    this.$el.find('tr.loading').remove();
  }
});

var BooksTable = Tableling.Bootstrap.Table.extend({

  tableView : BooksTableView,
  tableViewOptions : {
    template: 'booksTableView',
    collection: new BooksCollection({
      model: Book
    })
  },
  pageSizeViewOptions : {
    sizes : [ 5, 10, 15 ]
  }
});

$(function() {

  var table = new BooksTable({
    pageSize: 5,
    fetchOptions: {
      type: 'POST'
    }
  });

  new Backbone.Marionette.Region({
    el: '#books'
  }).show(table);
});

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
tableling-rails-0.0.26 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.25 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.24 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.23 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.22 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.21 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.20 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.19 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.18 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.17 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.16 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.15 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.14 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.13 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.12 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.11 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.10 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.9 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.8 spec/dummy/app/assets/javascripts/books.js
tableling-rails-0.0.7 spec/dummy/app/assets/javascripts/books.js