table-view.js 1.08 KB
var tt_id;

function template_form_init() {
    "use strict";
    $('#template-edit-form').find('select[multiple]').multiSelect({
        minWidth: 120
    });
}

function load_template() {
    "use strict";
    tt_id = parseInt($('#id_table_template').val(), 10);
    $.ajaxJSON({
        method: 'get',
        url: $dj.ajax_load_template,
        data: {template_id: tt_id},
        dest: $('#template-edit-form'),
        callback: template_form_init
    });
    $.ajaxJSON({
        method: 'get',
        url: $dj.ajax_preview_form,
        data: {template_id: tt_id},
        dest: $('#template-preview')
    });
}

function load_preview() {
    "use strict";
    $.ajaxJSON({
        method: 'get',
        url: $dj.ajax_load_preview,
        data: {
            template_id: tt_id,
            pattern_type_id: $('#id_pattern_type').val(),
            ic_id: $('#id_inflection_characteristic').val()
        },
        dest: $('#preview-table')
    });
}

$(function() {
    "use strict";
    $('#load-template').click(load_template);
    $(document).on('click', '#load-preview', load_preview);
});