Sha256: 77d41fbfa9bc2256684e5951b88a96cd10a9072c107ad34c9342621a0768619d

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

- model_name = controller_name.classify.constantize
.page-header
  %h1
    Сортировка 
    %small
      Вы можете перетаскивать строки в таблице

= form_tag action: :sort, method: :post do
  %table.table.table-striped
    %thead
      %tr
        %th.span12= model_name.human_attribute_name(attribute_name)
    %tbody
      - self.instance_variable_get("@#{controller_name}").each do |sortable|
        %tr
          = hidden_field_tag "#{controller_name}[#{sortable.id}]", sortable.id
          %td= sortable.send(attribute_name)
  = actions do
    = submit_tag 'Сохранить', class: 'btn btn-success'
    = cancel_action action: :index

:javascript
  $('#content tbody').sortable({
    axis: 'y',
    cursor: 'move',
    helper: function(e, tr) {
      var $originals = tr.children();
      var $helper = tr.clone();
      $helper.children().each(function(index) {
        $(this).width($originals.eq(index).width())
      });
      return $helper;
    }
  }).disableSelection();

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coalla-cms-0.4.2.0 app/views/admin/base/_sort.haml
coalla-cms-0.4.4.3 app/views/admin/base/_sort.haml