0
我有問題傳遞參數到我的模態窗口。我特別喜歡傳遞按鈕href,但似乎沒有出現在我的模式。將參數傳遞給模態
任何人都可以指出我正確的方向嗎?
的Javascript
<script>
$(document).ready(function() {
$('#confirm-delete').on('shown.bs.modal', function(event) {
$("#roomId").val($(event.relatedTarget).data('id'));
var roomId = $(e.relatedTarget).data('id');
$(e.currentTarget).find('input[name="roomId"]').val(roomId);
$('.url').html('Delete URL: <strong>' + $(this).find('.btn-danger').attr('href') + '</strong>');
});
});
</script>
莫代爾
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
</div>
<div class="modal-body">
<p>You are about to delete. Do you want to proceed?</p>
<input type="text" name="roomId" value=""/>
<div class="url"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<a href="#" class="btn btn-danger danger">Delete</a>
</div>
</div>
</div>
鏈接模態
<button data-href="/admin/rooms/delete/{{ $room->id }}" data-id="{{ $room->id}}" data-toggle="modal" data-target="#confirm-delete" href="#" type="button" class="btn btn-danger">Delete</button>
我覺得行,你分配的href問題'$( 'URL ')HTML(' 刪除網址:' + $(this).find('。btn-danger')。attr('href')+'');'你從元素中讀取href,在$(this)這是模態div下的btn-danger,我想你想讀鏈接到模態的按鈕的href – mfarouk 2014-10-01 07:58:57