File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change 23
23
gem ' activeadmin-sortable'
24
24
```
25
25
26
+ ### Include the JavaScript in active_admin.js
27
+
28
+ ``` javascript
29
+ // = require activeadmin-sortable
30
+ ```
31
+
26
32
### Configure your ActiveAdmin Resource
27
33
28
34
``` ruby
Original file line number Diff line number Diff line change
1
+ //= require jquery-ui
2
+
3
+ ( function ( $ ) {
4
+ $ ( document ) . ready ( function ( ) {
5
+ $ ( '.handle' ) . closest ( 'tbody' ) . activeAdminSortable ( ) ;
6
+ } ) ;
7
+
8
+ $ . fn . activeAdminSortable = function ( ) {
9
+ this . sortable ( {
10
+ update : function ( event , ui ) {
11
+ var url = ui . item . find ( '[data-sort-url]' ) . data ( 'sort-url' ) ;
12
+
13
+ $ . ajax ( {
14
+ url : url ,
15
+ type : 'post' ,
16
+ data : { position : ui . item . index ( ) + 1 } ,
17
+ success : function ( ) { window . location . reload ( ) }
18
+ } ) ;
19
+ }
20
+ } ) ;
21
+
22
+ this . disableSelection ( ) ;
23
+ }
24
+ } ) ( jQuery ) ;
Original file line number Diff line number Diff line change 1
1
require 'activeadmin-sortable/version'
2
2
require 'activeadmin'
3
+ require 'rails/engine'
3
4
4
5
module ActiveAdmin
5
6
module Sortable
@@ -22,8 +23,14 @@ def sortable_handle_column
22
23
end
23
24
end
24
25
end
25
- end
26
26
27
- ::ActiveAdmin ::ResourceDSL . send ( :include , Sortable ::ControllerActions )
28
- ::ActiveAdmin ::Views ::TableFor . send ( :include , Sortable ::TableMethods )
27
+ ::ActiveAdmin ::ResourceDSL . send ( :include , ControllerActions )
28
+ ::ActiveAdmin ::Views ::TableFor . send ( :include , TableMethods )
29
+
30
+ class Engine < ::Rails ::Engine
31
+ # Including an Engine tells Rails that this gem contains assets
32
+ end
33
+ end
29
34
end
35
+
36
+
You can’t perform that action at this time.
0 commit comments