Skip to content

Commit

Permalink
Add this.blur() to manual AJAX example
Browse files Browse the repository at this point in the history
Because the modal cannot infer the anchor that triggered the open, we must explicitly blur it. Otherwise the link remain focused and the modal will be re-triggered each time the `return` key is hit.
  • Loading branch information
kylefox committed Oct 18, 2017
1 parent 640c28f commit 23074d7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ <h2 id="example-4"><a href="#example-4">#</a> Example 4: AJAX</h2>
<pre><code>// Open modal in AJAX callback
$('#manual-ajax').click(function(event) {
event.preventDefault();
this.blur(); // Manually remove focus from clicked link.
$.get(this.href, function(html) {
$(html).appendTo('body').modal();
});
Expand Down Expand Up @@ -494,6 +495,7 @@ <h2 id="example-8"><a href="#example-8">#</a> Example 8: Custom Class for Close

$('#manual-ajax').click(function(event) {
event.preventDefault();
this.blur();
$.get(this.href, function(html) {
$(html).appendTo('body').modal();
});
Expand Down

0 comments on commit 23074d7

Please sign in to comment.