所以我做了一个管理页面,使用laravel,admin-lte,bootstrap等。
我制作了许多表格,并用它来编辑和删除数据(特别是显示数据)
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var recipient = button.data('whatever') // Extract info from data-* attributes
// If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
// Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
var modal = $(this)
modal.find('.modal-title').text('New message to ' + recipient)
modal.find('.modal-body input').val(recipient)
})
当我将它用于第一个表('pereli')时,一切都很好,没有任何问题。但是,当我对另一个表(“ tim”)执行相同的操作时,它只是无法单击“编辑”按钮并显示数据。
第一个,用于master.blade.php:
A。 “佩雷利”
<script>
$('#edit_pereli').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var namapereli = button.data('mynamapereli')
var jenispereli = button.data('myjenispereli')
var ttlpereli = button.data('myttlpereli')
var lahirpereli = button.data('mylahirpereli')
var domisilipereli = button.data('mydomisilipereli')
var rallypertamapereli = button.data('myrallypertamapereli')
var gelarrallypereli = button.data('mygelarrallypereli')
var gelarsprintpereli = button.data('mygelarsprintpereli')
var biografipereli = button.data('mybiografipereli')
var medsospereli = button.data('mymedsospereli')
var idpereli = button.data('myidpereli')
var modal = $(this)
modal.find('.modal-body #nama_pereli').val(namapereli);
modal.find('.modal-body #jenis_kelamin_pereli').val(jenispereli);
modal.find('.modal-body #tanggal_lahir_pereli').val(ttlpereli);
modal.find('.modal-body #tempat_lahir_pereli').val(lahirpereli);
modal.find('.modal-body #domisili_pereli').val(domisilipereli);
modal.find('.modal-body #rally_pertama_pereli').val(rallypertamapereli);
modal.find('.modal-body #gelar_pereli_rally').val(gelarrallypereli);
modal.find('.modal-body #gelar_pereli_sprintrally').val(gelarsprintpereli);
modal.find('.modal-body #biografi_pereli').val(biografipereli);
modal.find('.modal-body #link_medsos_pereli').val(medsospereli);
modal.find('.modal-body #id_pereli').val(idpereli);
})
$('#hapus_pereli').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var idpereli = button.data('myidpereli')
var modal = $(this)
modal.find('.modal-body #id_pereli').val(idpereli);
})
</script>
B。 “蒂姆”
<script>
//TIM
$('#edit_tim').on('show.bs.modal', function (event) {
var button1 = $(event.relatedTarget)
var namatim = button.data('mynamatim')
var tahuntim = button.data('mytahuntim')
var pemiliktim = button.data('mypemiliktim')
var homebasetim = button.data('myhomebasetim')
var principaltim = button.data('myprincipaltim')
var rallypertamatim = button.data('myrallypertamatim')
var gelarrallytim = button.data('mygelarrallytim')
var gelarsprinttim = button.data('mygelarsprinttim')
var biografitim = button.data('mybiografitim')
var websitetim = button.data('mywebsitetim')
var medsostim = button.data('mymedsostim')
var tim_id = button1.data('timid')
var modal = $(this)
modal.find('.modal-body #nama_tim').val(namatim);
modal.find('.modal-body #tahun_berdiri_tim').val(tahuntim);
modal.find('.modal-body #pemilik_tim').val(pemiliktim);
modal.find('.modal-body #homebase_tim').val(homebasetim);
modal.find('.modal-body #principal_tim').val(principaltim);
modal.find('.modal-body #rally_pertama_tim').val(rallypertamatim);
modal.find('.modal-body #gelar_tim_rally').val(gelarrallytim);
modal.find('.modal-body #gelar_tim_sprintrally').val(gelarsprinttim);
modal.find('.modal-body #biografi_tim').val(biografitim);
modal.find('.modal-body #website_tim').val(websitetim);
modal.find('.modal-body #link_medsos_tim').val(medsostim);
modal.find('.modal-body #tim_id').val(tim_id);
})
</script>
我的第一个念头是因为我把这两个分开了,但是当我把它们都放在一个下面时,它仍然不起作用。
我的讲师曾经说过,应该将其分开,使其成为两个“ master.blade”。但是我不确定。
反正这是我第一次来这里...