2017-09-25 1 views
2

J'utilise Laravel 5.4 avec des lames + DataTables et je voudrais utiliser Bubble Editor (datatables), comme par exemple sur: https://editor.datatables.net/examples/bubble-editing/simpledatatables automatique obtenir des valeurs thead pour l'éditeur Bubble (Laravel + Blades)

mais je reçois mon nom de theads de Blades et non d'un json. Comment puis-je obtenir un éditeur de bulles comme ça?

<table id="main_grid" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%"> 
     <thead id='main_grid_thead'> 
      <tr> 
       @foreach($tablefields as $field) 
        <th>{{ $field['detail_field']['grid']['label'] }}</th> 
       @endforeach 
      </tr> 
     </thead> 
     <tbody> 
      <!-- TABLE BODY HERE--> 
     </tbody> 
    </table> 

Et je suis une fonction JS avec datatables

var editor = new $.fn.dataTable.Editor({ 
     ajax: "../php/staff.php", 
     table: '#'+id_grid 
     }); 

    $('#'+id_grid).dataTable({ 
      sInfo: '', 
      "sDom": '<"html5buttons"B><"top"fZ>rt<"bottom"lpi><"clear"> ', 
      "oListNav": { 
        //SOME CODE 
      }, 
      pageLength: 10, 
      responsive: true, 

     }); 


    $('#' + id_grid).on('click', 'tbody td:not(:first-child)', function (e) { 
      editor.bubble($('#' + id_grid + ' tbody tr:first-child td:first-child')); 
     }); 

Répondre

1

J'ai trouvé une solution

$('#' + id_grid).on('click', 'tbody td i', function (e) { 
$(this).parent().children('i').attr('style','display:none; float: right;') 
    editor.bubble($(this).parent())