2017-10-27 1 views
0

Ich verwende die Schaltfläche, um die Details der bestimmten Person anzuzeigen, die das Daten-Toggle = "modal" verwendet, aber die Schaltfläche führt keine Aktion aus. Wenn ich auf die Schaltfläche klicke, kann ich keine Details des Benutzers anzeigen.Anzeigen von Daten aus dem Blade-Modell mit der Klick-Funktion

Route:

Route::get('document', '[email protected]'); 

Controller:

public function show() 
    { 
     $patient_user=patient_user::all(); 
     return view('document')->with('patient_user',$patient_user); 
    } 

Ausblick:

<form id="myForm" method="get"> 
    <input type="hidden" name="_token" value="{{ csrf_token() }}"> 
     <div class="panel-body"> 
      <table class="table table-striped table-bordered table-hover table-full-width" id="sample_1"> 
       <thead> 
        <tr> 
         <th>Patient ID</th> 
         <th>Patient Name</th> 
         <th>Full Name</th> 
         <th>DOB</th> 
         <th>Ref. Name</th> 
         <th>Payment</th> 
         <th>Doc Status</th> 
         <th>Appointment</th> 
         <th>Action</th> 
        </tr> 
       </thead> 
       @foreach($patient_user as $key=>$row) 
       <tbody> 
        <tr> 
         <td>{{$row->patient_id}}</td> 
         <td>{{$row->patient_firstname}}</td> 
         <td>{{$row->patient_firstname}} {{$row->patient_lastname}}</td> 
         <td>{{$row->dob}}</td> 
         <td>{{$row->refering_physician_name}}</td> 
         <td>{{$row->dob}} </td> 
         <td>{{$row->dob}}</td> 
         <td>{{$row->app_date}}</td> 
         <td class="center"> 
          <div class="visible-md visible-lg hidden-sm hidden-xs"> 
           <a href='{{ url("Trail/{$row->patient_id}") }}' class="btn btn-xs btn-teal tooltips" data-placement="top" data-original-title="Edit"><i class="fa fa-edit"></i></a> 
           <a href='#' data-toggle="modal" class="btn btn-xs btn-green tooltips" data-id="{{ $row->patient_id}}" data-target="static" onclick="pat_det{{ $row->patient_id }}" data-placement="top" data-original-title="View" id="pat_det"><i class="fa fa-eye"></i></a> 
           <a href='{{ url("destroy/{$row->patient_id}") }}' class="btn btn-xs btn-bricky tooltips" data-placement="top" data-original-title="Remove"><i class="fa fa-times fa fa-white"></i></a> 
          </div> 
         </td> 
        </tr> 
       </tbody> 
       @endforeach 
      </table> 
     </div> 
     <div id="static" class="modal fade" tabindex="-1" data-backdrop="static" data-keyboard="false" style="display: none;"> 
      <div class="modal-body"> 
       <h4><i>Patient Details</i></h4> 
      </div> 
      <div class="modal-body"> 
       <div class="col-md-12"> 
        <div class="col-md-6">First Name</div> 
        <div class="col-md-5" id="fname"> {{ $row->patient_firstname}} </div> 
       </div> 
       <br> 
       <div class="col-md-12"> 
        <div class="col-md-6">Middle Name</div> 
        <div class="col-md-5" id="mname"> {{ $row->middle_name}} </div> 
       </div> 
       <br> 
       <div class="col-md-12"> 
        <div class="col-md-6">Last Name</div> 
        <div class="col-md-5" id="lname"> {{ $row->patient_lastname}} </div> 
       </div> 
      </div> 
     </div> 
</form> 

jquery:

<script type="text/javascript"> 
    $('#static').on('show', function(e) 
    { 
       e.preventDefault(); 
       var link  = e.relatedTarget(), 
       modal = $(this), 
       patient_firstname = link.data("patient_firstname"), 
       middle_name = link.data(middle_name), 
       patient_lastname = link.data("patient_lastname"), 

       modal.find("#fname").val(patient_firstname); 
       modal.find("#mname").val(middle_name); 
       modal.find("#lname").val(patient_lastname); 

    }); 
</script> 

wobei #static meine modale ID ist und der Wert innerhalb der Suche die IDs der einzelnen Felder und val die Datenbankwerte sind.

+0

Hallo, hast du überprüft, dass du den Wert von "patient_firstname", "middle_name", "patient_lastname" findest, wenn Modal die Show ist? –

+0

Sie verwenden die Funktion jQuery [.data()] (https://api.jquery.com/data/). Allerdings haben Sie diese 'data-*' Attribute nirgends gesetzt. –

+0

es zeigt nichts die Schaltfläche selbst führt keine Aktion aus @RenishKhunt – Amruta

Antwort

0

Das Problem besteht darin, dass Sie Daten von Attributen anfordern, die nicht festgelegt sind.

patient_firstname = link.data("patient_firstname"), 

Der obige Teil versucht, den Wert des Attributs data-patient_firstname abzurufen. Da die ursprüngliche Verknüpfung dieses Attribut nicht aufweist, werden keine Daten vorhanden sein.

ändern

<a href='#' data-toggle="modal" class="btn btn-xs btn-green tooltips" data-id="{{ $row->patient_id}}" data-target="static" onclick="pat_det{{ $row->patient_id }}" data-placement="top" data-original-title="View" id="pat_det"><i class="fa fa-eye"></i></a> 

In

<a href='#' data-toggle="modal" 
data-patient_firstname="{{$row->patient_firstname}}" <-- do this for all requested vars 
class="btn btn-xs btn-green tooltips" data-id="{{ $row->patient_id}}" data-target="static" onclick="pat_det{{ $row->patient_id }}" data-placement="top" data-original-title="View" id="pat_det"><i class="fa fa-eye"></i></a> 

auf diese Weise die data-* Attribute availble sein.

+0

Ich machte die Änderungen noch die Schaltfläche führt keine Aktion aus, wenn ich auf die Schaltfläche klicke, es ist konstant, nur keinen Wert oder Fehler zu geben. @Peter M – Amruta

+0

Gibt es Fehler in der Konsole? –

+0

Keine Fehler in der Konsole. @ Peter M – Amruta

Verwandte Themen