From 1339ab7a130600330b1db4e3acae9760710a0a41 Mon Sep 17 00:00:00 2001 From: hillai Date: Thu, 30 Oct 2014 18:13:39 +0200 Subject: Replace v3.2.1 reference with v3.3.0 since there wasn't a v3.2.1 Closes #14941 --- docs/_includes/js/modal.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/_includes/js/modal.html') diff --git a/docs/_includes/js/modal.html b/docs/_includes/js/modal.html index e47464a4c..1bb606ab8 100644 --- a/docs/_includes/js/modal.html +++ b/docs/_includes/js/modal.html @@ -262,7 +262,7 @@ path false -

This option is deprecated since v3.2.1 and will be removed in v4. We recommend instead using client-side templating or a data binding framework, or calling jQuery.load yourself.

+

This option is deprecated since v3.3.0 and will be removed in v4. We recommend instead using client-side templating or a data binding framework, or calling jQuery.load yourself.

If a remote URL is provided, content will be loaded one time via jQuery's load method and injected into the .modal-content div. If you're using the data-api, you may alternatively use the href attribute to specify the remote source. An example of this is shown below:

{% highlight html %} Click me -- cgit v1.2.3 From 594831f4f3f3c1164812cfdd60497fe6d7438376 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 3 Nov 2014 13:37:27 -0800 Subject: Add event.relatedTarget + `data-*` example to Modal docs Fixes #14245 --- docs/_includes/js/modal.html | 80 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'docs/_includes/js/modal.html') diff --git a/docs/_includes/js/modal.html b/docs/_includes/js/modal.html index 1bb606ab8..22924b4e7 100644 --- a/docs/_includes/js/modal.html +++ b/docs/_includes/js/modal.html @@ -211,6 +211,86 @@ +{% endhighlight %} + + +

Have a bunch of buttons that all trigger the same modal, just with slightly different contents? Use event.relatedTarget and HTML data-* attributes (possibly via jQuery) to vary the contents of the modal depending on which button was clicked. See the Modal Events docs for details on relatedTarget,

+
+ + + + ...more buttons... + + +
+{% highlight html %} + + + +...more buttons... + + +{% endhighlight %} +{% highlight js %} +$('#exampleModal').on('show.bs.modal', function (event) { + var button = $(event.relatedTarget) // Button that triggered the modal + var recipient = button.data('whatever') // Extract info from data-* attributes + // If necessary, you could initiate an AJAX request here (and then do the updating in a callback). + // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead. + var modal = $(this) + modal.find('.modal-title').text('New message to ' + recipient) + modal.find('.modal-body input').val(recipient) +}) {% endhighlight %}

Usage

-- cgit v1.2.3