我有以下代碼,我想知道如何將數(shù)據(jù)從表傳遞到模態(tài)這是我在 edit.blade.php 中的代碼。模式確實(shí)有效,但我不知道如何使數(shù)據(jù)顯示在模式中,我會(huì)自己 POST 到數(shù)據(jù)庫,但我只想知道如何顯示該數(shù)據(jù),以便我可以編輯它。我想在模態(tài)中顯示的數(shù)據(jù)是 ID、姓名和電子郵件。這是我在 editar.blade.php 中的代碼<script src="{{ url('/js/vendor/jquery-1.12.4.min.js') }} "></script><script src="{{ url('/js/bootstrap.min.js') }} "></script><link rel="stylesheet" href="{{ url('/css/bootstrap.min.css') }} "><script src="{{ url('/js/jquery.dataTables.min.js') }} "></script><div class="container"> <h2>Editar estudiante</h2><div class="container"> <h2>Laravel DataTables Tutorial Example</h2> <table id="user_table" class="table table-bordered table-striped"> <thead> <tr> <th width="35%" id="name">Name</th> <th width="35%" id="email">Email</th> <th width="30%">Action</th> </tr> </thead> </table></div><div class="modal fade" id="edit-modal" tabindex="-1" role="dialog" aria-labelledby="edit-modal-label" aria-hidden="true"> <div class="modal-dialog modal-lg" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="edit-modal-label">Edit Data</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> </button> </div> <div class="modal-body" id="attachment-body-content"> <form id="edit-form" class="form-horizontal" method="POST"> <div class="card text-white bg-dark mb-0"> <div class="card-header"> <h2 class="m-0">Edit</h2> </div>
1 回答

吃雞游戲
TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊
你能試試這個(gè)嗎?
$('#modal-input-name').val($tr.find('td.user-name').text()); $('#modal-input-email').val($tr.find('td.user-email').text());
另外,我建議您使用 acss
class
來定位點(diǎn)擊事件,就像Id
通常用于唯一標(biāo)識(shí)符一樣,并且按照您的方式,您將擁有許多具有相同內(nèi)容的表行Id
,這違背了最初的想法。
- 1 回答
- 0 關(guān)注
- 98 瀏覽
添加回答
舉報(bào)
0/150
提交
取消