<p>Link 1</p>
<a data-toggle="modal" data-id="ISBN564541" title="Add this item" class="open-AddBookDialog btn btn-primary" href="#addBookDialog">test</a>
<p> </p>
<p>Link 2</p>
<a data-toggle="modal" data-id="ISBN-001122" title="Add this item" class="open-AddBookDialog btn btn-primary" href="#addBookDialog">test</a>
<div class="modal hide" id="addBookDialog">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>some content</p>
<input type="text" name="bookId" id="bookId" value=""/>
</div>
</div>
$(document).on("click", ".open-AddBookDialog", function () {
var myBookId = $(this).data('id');
$(".modal-body #bookId").val( myBookId );
// As pointed out in comments,
// it is superfluous to have to manually call the modal.
// $('#addBookDialog').modal('show');
});
https://stackoverflow.com/questions/10626885/passing-data-to-a-bootstrap-modal
'JS' 카테고리의 다른 글
javascript How to force reloading a page when using browser back button? (0) | 2018.08.06 |
---|---|
TypeError: Path must be a string. Received undefined TypeError: Cannot read property 'file' of undefined (0) | 2018.08.03 |
실시간으로 생긴 태그 클릭 안될 때 (0) | 2018.07.30 |
append() html() prepend() (0) | 2018.07.30 |
Node js와 Brackets 설치, 오류 수정 (0) | 2018.06.09 |