Skip to content

Instantly share code, notes, and snippets.

@PunchRockgroin
Last active August 30, 2019 20:04
Show Gist options
  • Save PunchRockgroin/ce4970fad658dbf8c9f468701a40ebff to your computer and use it in GitHub Desktop.
Save PunchRockgroin/ce4970fad658dbf8c9f468701a40ebff to your computer and use it in GitHub Desktop.
Gravity Perks Limit Choices add message when no more choices available
// Add classname .choicless-message to field in GF Admin
$('.choiceless-message').each(function() {
let $el = $(this)
let inputsWithChoice = $el.find('input').length
let inputsWithChoiceDisabled = $el.find('input:disabled').length
let waitlistHref = $el.data('waitlistHref') || '#'
if (inputsWithChoice === inputsWithChoiceDisabled) {
$('<div />').addClass('alert alert-warning').html('<p class="mb-0">There are no more open slots available<br /> <a href=".waitlistHref.">Join the waitlist</a></p>').appendTo($el)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment