Note that there are some explanatory texts on larger screens.

plurals
  1. POPass an ID To Twitter Bootstrap Model
    primarykey
    data
    text
    <p>I am trying to pass an id to a twitter bootstrap model for a delete confirmation (basic CRUD page) and for the life of me I can't get this working. Looked at several examples still unable to get to work. I need to get the data-id to pass to the model and append the href link so that for example they confirm it takes them to the appropiate page (eg: delete.php?id=5) Any ideas would be greatly appreciated. Heres my code:</p> <p><strong>The link:</strong></p> <pre><code>&lt;a href="#msgDelete" data-toggle="modal" class="open-dialog btn btn-mini btn-danger" data-id="'.$row["id"].'"&gt; </code></pre> <p><strong>The Model:</strong></p> <pre><code>&lt;div id="msgDelete" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt; &lt;div class="modal-header"&gt; &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt; &lt;h3 id="myModalLabel"&gt;Are You Sure?&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;p&gt;Are you sure you want to delete this product? This action can not be reversed. &lt;br /&gt;&lt;br /&gt;&lt;em&gt;Remember if you want to just hide the product from your store you can mark it as inactive.&lt;/em&gt;&lt;/p&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Cancel&lt;/button&gt; &lt;a href="delete.php?id=" class="btn btn-danger" id="clink" &gt;Delete Product&lt;/a&gt; &lt;/div&gt; </code></pre> <p><strong>The JavaScript:</strong></p> <pre><code>&lt;script type="text/javascript"&gt; $(document).on("click", ".open-dialog", function () { var productId = $(this).data('id'); console.log(productId); //$(".modal-body #clink").href( 'delete.php?id=' + productId ); $("#clink").attr("href", "delete.php?idd=" + productId); // As pointed out in comments, // it is superfluous to have to manually call the modal. // $('#addBookDialog').modal('show'); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    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