Sha256: d1af69601a1ace043572cbd78ae7dd95b74669219226055f17fbe840a79f7f6a
Contents?: true
Size: 763 Bytes
Versions: 1
Compression:
Stored size: 763 Bytes
Contents
Trestle.init(function(e, root) { $(root).find("a[data-toggle='tab']").on('shown.bs.tab', function(e) { var hash = $(this).attr("href"); if (hash.substr(0, 1) == "#") { history.replaceState({ turbolinks: {} }, "", "#!" + hash.substr(1)); } }); }); Trestle.focusActiveTab = function() { if (location.hash.substr(0, 2) == "#!") { // Focus on active tab from URL $("a[data-toggle='tab'][href='#" + location.hash.substr(2) + "']").tab("show"); } else if ($(".tab-pane:has(.has-error)").length) { // Focus on first tab with errors var pane = $(".tab-pane:has(.has-error)").first(); $("a[data-toggle='tab'][href='#" + pane.attr("id") + "']").tab("show"); } }; Trestle.ready(function() { Trestle.focusActiveTab(); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trestle-0.8.6 | app/assets/javascripts/trestle/components/_tabs.js |