Sha256: 5af86a5c3d74bed741b3aa585e080d7d2a1e0c6fe3cdb4e3ad8d6c6ddeb1d06d

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

/* Admin table */

$(document).on("ready page:load", function() {
  
  var tableButtons = $('.table_buttons'),
      editButton = tableButtons.find('a[class="edit"]'),
      deleteButton = tableButtons.find('a[class="delete"]'),
      path = window.location.pathname + '/';
      table = $("#admin_table");

  // add ajax to the pagination
  table.on("click", ".pagination a", function() {
    $.getScript(this.href);
    return false;
  });

  // line clickable
  table.on("click", "tbody tr", function(e) {
    var id = $(this).data('url') ;
    if ( typeof id !== 'undefined' && !$(this).hasClass('selected') ) {
      $('tr.selected').removeClass('selected');
      $(this).addClass('selected');
      deleteButton.add(editButton).addClass("on");
      editButton.attr('href', path + id + '/edit');
      deleteButton.attr('href', path + id);
    }
  });

  // Double click
  table.on("dblclick", "tbody tr", function() {
    var id = $(this).data('url');
    if ( typeof id !== 'undefined' ) {
      window.location = path + id + '/edit';
    }
  });

});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
snaptable-0.3.0 app/assets/javascripts/autotable.js
snaptable-0.2.1 app/assets/javascripts/autotable.js
snaptable-0.2.0 app/assets/javascripts/autotable.js