第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Laravel 將舊值或值傳遞給模態(tài)

Laravel 將舊值或值傳遞給模態(tài)

PHP
冉冉說 2023-07-08 16:38:52
看起來 Modal 不太容易大規(guī)模實(shí)現(xiàn),我想找到一種替代方法將值傳遞給模態(tài)以便正確顯示它。在下面的示例中,我從數(shù)據(jù)表本身填充“名稱”字段,這很好用,但是如果我想傳遞,該怎么辦old('name') ?? $document->name我怎樣才能大規(guī)模地完成這個(gè)任務(wù),比如 10 個(gè)以上的字段條目?按鈕<a href="#"><i class="bx bxs-edit text-primary bx-sm edit" title="Edit Document"></i></a>腳本<script type="text/javascript">$(document).ready( function () {    var table = $('#indextable').DataTable();        //Edit Record    table.on('click', '.edit', function(){       $tr = $(this).closest('tr');       if ($($tr).hasClass('child')){           $tr = $tr.prev('.parent');       }        //Config Table        var data = table.row($tr).data();        $('#name').val(data[1]);                $('#editForm').attr('action', '/virtual/documents/'+data[0]);        $('#editModal').modal('show');    });        $("#editForm").submit(function () {        $(".submit").attr("disabled", true);            return true;    });});@if (count($errors) > 0)    $('#editModal').modal('show');@endif</script>
查看完整描述

2 回答

?
天涯盡頭無女友

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊

這是有意義的解決方案。


步驟1)在按鈕中添加數(shù)據(jù)-###,并且它必須位于指定標(biāo)題之前。


<a href="#"><i class="bx bxs-edit text-primary bx-sm edit" data-name="{{old('name') ?? $document->name}} " title="Edit Document"></i></a>

步驟2)在腳本中,您可以使用示例“$(this).data('name');”來獲取數(shù)據(jù)


<script type="text/javascript">

$(document).ready( function () {

    //Getting the datatable ready

    var table = $('#indextable').DataTable();

    //if the edit button is clicked

    table.on('click', '.edit', function(){

        var nameData = $(this).data('name');

        $("#name").val(nameData);

        $('#editModal').modal('show');

    });

});

//On error keep the modal open

@if (count($errors) > 0)

    $('#editModal').modal('show');

@endif

</script>


查看完整回答
反對(duì) 回復(fù) 2023-07-08
?
慕虎7371278

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超4個(gè)贊

例如,另一種選擇是重新刷新會(huì)話;


//On error keep the modal open

@if (count($errors) > 0)

    {{ Session::reflash()}}

    $('#editModal').modal('show');

@endif

old('value')然后您可以在模態(tài)視圖中使用標(biāo)準(zhǔn)語法。


查看完整回答
反對(duì) 回復(fù) 2023-07-08
  • 2 回答
  • 0 關(guān)注
  • 167 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)