Sha256: 3762a2bce79c8d599f619c22b75b18fdd9b507c90bb3cfde7797b099befd8de9

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

/* Admin table */

function snapifyTable() {
  
  var snaptable = $('#snaptable')

  var tableButtons = snaptable.find('.table_buttons'),
      editButton = tableButtons.find('a[class="edit"]'),
      deleteButton = tableButtons.find('a[class="delete"]'),
      path = window.location.pathname + '/';

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

  // line clickable
  snaptable.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
  snaptable.on("dblclick", "tbody tr", function() {
    var id = $(this).data('url');
    if ( typeof id !== 'undefined' ) {
      window.location = path + id + '/edit';
    }
  });

}

$(document).on("ready page:load", function() {

  snapifyTable();

});

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
snaptable-0.7.0 app/assets/javascripts/snaptable/table.js
snaptable-0.6.4 app/assets/javascripts/snaptable/table.js
snaptable-0.6.3 app/assets/javascripts/snaptable/table.js
snaptable-0.6.1 app/assets/javascripts/snaptable/table.js
snaptable-0.6.0 app/assets/javascripts/snaptable/table.js
snaptable-0.5.1 app/assets/javascripts/snaptable/table.js
snaptable-0.5.0 app/assets/javascripts/snaptable/table.js
snaptable-0.4.2 app/assets/javascripts/snaptable/table.js
snaptable-0.4.1 app/assets/javascripts/snaptable.js
snaptable-0.4.0 app/assets/javascripts/snaptable.js