Skip to content

Instantly share code, notes, and snippets.

@Binternet
Created November 22, 2016 14:31
Show Gist options
  • Save Binternet/cf524a374c351ab396100d0ee91e0688 to your computer and use it in GitHub Desktop.
Save Binternet/cf524a374c351ab396100d0ee91e0688 to your computer and use it in GitHub Desktop.
ACF Toggle Collapse in Repeater Field
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