table dragger a webpack

This commit is contained in:
f 2019-11-15 12:31:40 -03:00
parent b019d95e94
commit c00a827cb0
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
3 changed files with 16 additions and 15 deletions

View file

@ -1,6 +1,5 @@
//= require rails-ujs //= require rails-ujs
//= require turbolinks //= require turbolinks
//= require input-tag/input-tag.js //= require input-tag/input-tag.js
//= require table-dragger/dist/table-dragger
//= require zepto/dist/zepto.min.js //= require zepto/dist/zepto.min.js
//= require_tree . //= require_tree .

View file

@ -1,14 +0,0 @@
$(document).on('turbolinks:load', function() {
var table = document.querySelector('.table-draggable');
if (table == null) return;
tableDragger(table, {
mode: 'row',
onlyBody: true,
dragHandler: '.handle'
}).on('drop', function(from, to, el, mode) {
$('.reorder').val(function(i,v) { return i; });
$('.submit-reorder').removeClass('d-none');
});
});

View file

@ -17,3 +17,19 @@
require("trix") require("trix")
require("@rails/actiontext") require("@rails/actiontext")
import tableDragger from 'table-dragger'
document.addEventListener('turbolinks:load', () => {
const table = document.querySelector('.table-draggable');
if (table == null) return;
tableDragger(table, {
mode: 'row',
onlyBody: true,
dragHandler: '.handle'
}).on('drop', (from, to, el, mode) => {
$('.reorder').val((i,v) => i);
$('.submit-reorder').removeClass('d-none');
});
})