aboutsummaryrefslogtreecommitdiffstats
path: root/demos/tabs/sortable.html
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2016-11-09 10:13:10 +0100
committerFelix Nagel <info@felixnagel.com>2016-11-09 10:13:28 +0100
commit6b8ac7ef1ba05e879a09bd58dcd240f9cf16c8cb (patch)
treef5335d796b667c7a4a158ee754f756cc2dc18a52 /demos/tabs/sortable.html
parent68028e7262a14463b71539f4e3bca689e49acf33 (diff)
parentd85c68f6cdc02266ab8972e5c4159514b4d2598f (diff)
downloadjquery-ui-6b8ac7ef1ba05e879a09bd58dcd240f9cf16c8cb.tar.gz
jquery-ui-6b8ac7ef1ba05e879a09bd58dcd240f9cf16c8cb.zip
Merge branch 'master' into datepicker
Diffstat (limited to 'demos/tabs/sortable.html')
-rw-r--r--demos/tabs/sortable.html13
1 files changed, 12 insertions, 1 deletions
diff --git a/demos/tabs/sortable.html b/demos/tabs/sortable.html
index 051663ed4..9888cff77 100644
--- a/demos/tabs/sortable.html
+++ b/demos/tabs/sortable.html
@@ -9,10 +9,21 @@
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js" data-modules="sortable">
var tabs = $( "#tabs" ).tabs();
+ var previouslyFocused = false;
+
tabs.find( ".ui-tabs-nav" ).sortable({
axis: "x",
- stop: function() {
+
+ // Sortable removes focus, so we need to restore it if the tab was focused
+ // prior to sorting
+ start: function(event, ui) {
+ previouslyFocused = document.activeElement === ui.item[ 0 ];
+ },
+ stop: function(event, ui) {
tabs.tabs( "refresh" );
+ if (previouslyFocused) {
+ ui.item.focus();
+ }
}
});
</script>