mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #5909 from timkung/tabset-opentabfromurl-fix
Fixing TabSet.js error when expected elements are not available
This commit is contained in:
commit
53501c73bc
@ -1,5 +1,5 @@
|
|||||||
(function($){
|
(function($) {
|
||||||
$.entwine('ss', function($){
|
$.entwine('ss', function($) {
|
||||||
/**
|
/**
|
||||||
* Lightweight wrapper around jQuery UI tabs for generic tab set-up
|
* Lightweight wrapper around jQuery UI tabs for generic tab set-up
|
||||||
*/
|
*/
|
||||||
@ -34,11 +34,11 @@
|
|||||||
* @param {string} hash
|
* @param {string} hash
|
||||||
* @desc Allows linking to a specific tab.
|
* @desc Allows linking to a specific tab.
|
||||||
*/
|
*/
|
||||||
openTabFromURL: function (hash) {
|
openTabFromURL: function(hash) {
|
||||||
var $trigger;
|
var $trigger;
|
||||||
|
|
||||||
// Make sure the hash relates to a valid tab.
|
// Make sure the hash relates to a valid tab.
|
||||||
$.each(this.find('.cms-panel-link'), function () {
|
$.each(this.find('.ui-tabs-anchor'), function() {
|
||||||
// The hash in in the button's href and there is exactly one tab with that id.
|
// The hash in in the button's href and there is exactly one tab with that id.
|
||||||
if (this.href.indexOf(hash) !== -1 && $(hash).length === 1) {
|
if (this.href.indexOf(hash) !== -1 && $(hash).length === 1) {
|
||||||
$trigger = $(this);
|
$trigger = $(this);
|
||||||
@ -52,7 +52,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Switch to the correct tab when AJAX loading completes.
|
// Switch to the correct tab when AJAX loading completes.
|
||||||
$(window).one('ajaxComplete', function () {
|
$(document).ready(function() {
|
||||||
$trigger.click();
|
$trigger.click();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -66,7 +66,7 @@
|
|||||||
if (!$(this).attr('href')) return;
|
if (!$(this).attr('href')) return;
|
||||||
|
|
||||||
var matches = $(this).attr('href').match(/#.*/);
|
var matches = $(this).attr('href').match(/#.*/);
|
||||||
if(!matches) return;
|
if (!matches) return;
|
||||||
$(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);
|
$(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user