Last Updated: February 25, 2016
·
3.49K
· sspross

Django + Tastypie + Backbone.js = TastyBackbonePie

jQuery plugin to create ajax data tables using a django-tastypie api backend. Includes a way to easily paginate, sort and filter tables too.

Picture

https://github.com/sspross/tastybackbonepie

var book_table_settings = {
    uid: 'book_table',
    root_url: '/api/v1/book/',
    fields: [
        {
            'key': 'id',
            'label': '#',
        },
        {
            'key': 'name',
            'label': 'Name',
            'order_by': 'name',
        },
        {
            'key': 'added',
            'label': 'Added at',
            'order_by': 'added',
        },
        {
            'key': 'read',
            'label': 'Read',
            'template': '<% if (entry.get(\'read\') == true) { %>x<% } %>',
            'order_by': 'read',
        },
    ],
    additional_html_fields: [
        '<a class="btn btn-mini" href="#" data-id="<%= entry.get(\'id\') %>"><i class="icon-trash"></i></a>',
    ]
};

var book_table = $('#book-table').renderTastyBackbonePieTable(book_table_settings);

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside