@@ -46,8 +46,17 @@ function initDataTables(selector, options)
4646 options . sDom = "<'dt-toolbar'<'col-xs-12 col-sm-6'f><'col-sm-6 col-xs-12 hidden-xs'l>r>" +
4747 "t" +
4848 "<'dt-toolbar-footer'<'col-sm-6 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-6'p>>" ;
49+ options . drawCallback = function ( settings ) {
50+ $ ( '[data-toggle="tooltip"]' ) . tooltip ( ) ;
51+ }
52+
53+ // datatable
54+ var table = $ ( selector ) . DataTable ( options ) ;
55+
56+ // reregister the tooltip events on table
57+ table . $ ( '[data-toggle="tooltip"]' ) . tooltip ( ) ;
4958
50- return $ ( selector ) . DataTable ( options ) ;
59+ return table ;
5160}
5261
5362function getOrderBy ( element )
@@ -68,12 +77,23 @@ function getOrderBy(element)
6877 return orderBy ;
6978}
7079
71- function initActionDeleteClick ( )
80+ function initActionDeleteClick ( element )
7281{
7382 $ ( '.dt-table' ) . off ( 'click' , '.btn-delete-row' ) ;
83+ $ ( '.dt-table' ) . off ( 'click' , '.btn-confirm-modal-row' ) ;
84+ if ( element ) {
85+ element . off ( 'click' , '.btn-delete-row' ) ;
86+ element . off ( 'click' , '.btn-confirm-modal-row' ) ;
87+ }
7488
7589 // DELETE ROW LINK
7690 $ ( '.dt-table' ) . on ( 'click' , '.btn-delete-row' , onActionDeleteClick ) ;
91+ $ ( '.dt-table' ) . on ( 'click' , '.btn-confirm-modal-row' , onConfirmRowlick ) ;
92+
93+ if ( element ) {
94+ element . on ( 'click' , '.btn-delete-row' , onActionDeleteClick ) ;
95+ element . on ( 'click' , '.btn-confirm-modal-row' , onConfirmRowlick ) ;
96+ }
7797
7898 function onActionDeleteClick ( e )
7999 {
@@ -94,4 +114,21 @@ function initActionDeleteClick()
94114
95115 return false ;
96116 }
117+
118+ function onConfirmRowlick ( e )
119+ {
120+ e . preventDefault ( ) ;
121+ var formId = $ ( this ) . attr ( 'data-form' ) ;
122+ var title = $ ( this ) . attr ( 'data-original-title' ) ;
123+ title = '<strong>' + title + '</strong>' ;
124+
125+ var content = "Are you sure you want to " + title + "? " ;
126+ $ ( '#modal-confirm' ) . find ( '.modal-body' ) . find ( 'p' ) . html ( content ) ;
127+ $ ( '#modal-confirm' ) . find ( '.modal-footer' ) . find ( '.btn-primary' ) . on ( 'click' , function ( e )
128+ {
129+ $ ( '#' + formId ) . submit ( ) ;
130+ } ) ;
131+ $ ( '#modal-confirm' ) . modal ( 'show' ) ;
132+ return false ;
133+ }
97134}
0 commit comments