私はWebアプリケーションにLaravelを使用しています。ブートストラップモードの動的URL
「国」テーブルの各行には、モーダルを開き、テキストエリアに既存の国名を入力する「編集」ボタンがあります。このテキストエリアは、データベースで編集および更新できます。
これは私のモーダルの部分的なコードです:私がしたいことを同じスクリプトで
$(function() {
$('#editModal').on("show.bs.modal", function (e) {
$("#lblCountryId").html($(e.relatedTarget).data('id'));
document.getElementById("txtCountryName").value = $(e.relatedTarget).data('name');
});
});
:
{!! Form::model($country, [
'method' => 'PATCH',
'url' => ['country', 'lblCountryId'],
'class' => 'form-horizontal'
]) !!}
// some more code
// and the edit button for each row
<td>
<button type="submit" class="btn btn-primary btn-xs"
data-toggle="modal" data-target="#editModal"
data-id=" {{ $item->id }}"
data-name="{{ $item->name }}">
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
</td>
モーダルショー、私はJSをfolloringとテキストフィールドの値をmanupulateフォームが投稿しているURLを編集しますが、JSはそれを好きではありません。
クリックした行に応じてフォームのURLを動的に変更する方法はありますか?
フォームのターゲットURLを変更するコードを表示します。 –
"show.bs.modal"の代わりに "shown.bs.modal"を試しましたか? – Abhishek