Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing data to a bootstrap modal
    primarykey
    data
    text
    <p>I've got a couple of hyperlinks that each have an ID attached. When I click on this link, I want to open a modal ( <a href="http://twitter.github.com/bootstrap/javascript.html#modals" rel="noreferrer">http://twitter.github.com/bootstrap/javascript.html#modals</a> ), and pass this ID to the modal. I searched on google, but I couldn't find anything that could help me.</p> <p>This is the code:</p> <pre><code>&lt;a data-toggle="modal" data-id="@book.Id" title="Add this item" class="open-AddBookDialog"&gt;&lt;/a&gt; </code></pre> <p>Which should open:</p> <pre><code>&lt;div class="modal hide" id="addBookDialog"&gt; &lt;div class="modal-body"&gt; &lt;input type="hidden" name="bookId" id="bookId" value=""/&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>With this piece of code: </p> <pre><code>$(document).ready(function () { $(".open-AddBookDialog").click(function () { $('#bookId').val($(this).data('id')); $('#addBookDialog').modal('show'); }); }); </code></pre> <p>However, when I click the hyperlink, nothing happens. When I give the hyperlink a href="#addBookDialog", the modal opens just fine, but it does't contain any data.</p> <p>I followed this example: <a href="https://stackoverflow.com/questions/10379624/how-to-pass-values-arguments-to-modal-show-function-in-twitter-bootstrat">How to pass values arguments to modal.show() function in Bootstrap</a></p> <p>(and I also tried this: <a href="https://stackoverflow.com/questions/7845866/how-to-set-the-input-value-in-a-modal-dialogue">How to set the input value in a modal dialogue?</a>)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload