Skip to content

Commit 36cccca

Browse files
committed
Merge pull request BetterBrief#20 from BetterBrief/pulls/cms-invisible-tabs
Handle hidden fields in CMS tabs
2 parents 730be9f + 232c881 commit 36cccca

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

javascript/GoogleMapField.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,27 @@
123123
init();
124124
}
125125

126-
// Set the init method to re-run if the page is saved or pjaxed
127-
if($.entwine){
128-
$.entwine('ss', function($) {
129-
$('.googlemapfield').entwine({
130-
onmatch: function() {
131-
if(gmapsAPILoaded) {
132-
init();
133-
}
126+
// CMS stuff: set the init method to re-run if the page is saved or pjaxed
127+
// there are no docs for the CMS implementation of entwine, so this is hacky
128+
if(!!$.fn.entwine && $(document.body).hasClass('cms')) {
129+
(function setupCMS() {
130+
var matchFunction = function() {
131+
if(gmapsAPILoaded) {
132+
init();
134133
}
134+
};
135+
$.entwine('ss', function($) {
136+
$('.cms-tabset').entwine({
137+
onmatch: matchFunction
138+
});
139+
$('.cms-tabset-nav-primary li').entwine({
140+
onclick: matchFunction
141+
});
142+
$('.ss-tabset li').entwine({
143+
onclick: matchFunction
144+
});
135145
});
136-
});
146+
}());
137147
}
138148

139149
}(jQuery));

0 commit comments

Comments
 (0)