Created
November 22, 2016 14:31
-
-
Save Binternet/cf524a374c351ab396100d0ee91e0688 to your computer and use it in GitHub Desktop.
ACF Toggle Collapse in Repeater Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var imagesToggleCollapse = { | |
init: function(){ | |
var _ = this; | |
_.grabDOM(); | |
_.addButton(); | |
_.bindEvents(); | |
}, | |
grabDOM: function(){ | |
var _ = this; | |
// The tab that holds the images | |
_.$tab = $('div.acf-field-5761048e1ce83'); | |
}, | |
addButton: function() { | |
var _ = this; | |
$('<button class="button toggle-collapse" style="margin:20px">Toggle Collapse</button>').appendTo( _.$tab.find('label').eq(0) ); | |
}, | |
bindEvents: function() { | |
var _ = this; | |
$('body').on('click', '.toggle-collapse', function(){ | |
$( ".-collapse" ).each(function( index ) { | |
$( this ).click(); | |
}); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment