Skip to content

Instantly share code, notes, and snippets.

View theflowglenn's full-sized avatar

Glenn McWhinney theflowglenn

View GitHub Profile
@theflowglenn
theflowglenn / gist:1040942
Created June 22, 2011 19:37
Snippet from Rails 3 Client Side Validations JS to allow for AJAX spinner
// Set up the events for the form
form
.submit(function() { return form.isValid(settings.validators); })
// added loading toggle to handle the feedback spinner image (and changed 'beforeSend' to just 'before')
.bind('ajax:before', function() { $("#loading").toggle(); return form.isValid(settings.validators); })
.bind('ajax:success', function() { $("#loading").toggle(); })
// Callbacks
.bind('form:validate:after', function(eventData) { clientSideValidations.callbacks.form.after( form, eventData); })
.bind('form:validate:before', function(eventData) { clientSideValidations.callbacks.form.before(form, eventData); })
@theflowglenn
theflowglenn / setting-custom-checkbox-values.html
Created June 8, 2020 18:52
Used in Webflow projects when you want to use hidden Collections to set sensible values for checkboxes
<script>
// Dynamically create the Category dropdown from the Collection Data
$('.category-select-option-pair').each(function() {
var dv = $(this).children('div').eq(0).text();
var av = $(this).children('div').eq(1).text();
$('.category-dynamic-dropdown').append('<option value="' + av + '">' + dv + '</option>');
})
</script>