Skip to content

Instantly share code, notes, and snippets.

View vmcilwain's full-sized avatar

Vell vmcilwain

View GitHub Profile
@vmcilwain
vmcilwain / icheck_checkboxes.coffee
Last active November 1, 2018 11:44
Processing iCheck checkboxes
# Code for processing icheck checkboxes
# with slight modification it can be used with normal checkboxes as well
# Check or uncheck all checkboxes
#
$('#checkAll').on 'ifChecked ifUnchecked', (event) ->
$checkboxes = $(this).closest('form').find(':checkbox')
if event.type == 'ifChecked'
$checkboxes.prop 'checked', true
@vmcilwain
vmcilwain / trix_rails_from_tag
Created October 18, 2017 17:19
Adding trix editor to a rails form_tag (using haml)
# Given there is a section object and I would like to use trix editor for adding text to the content attribute
# id: is required to tie trix-editor(below to to the hidden input
# name: is required so that you can find it via params in the controller in this case params["trix-editor_section_#{section.id}"]
# content: is for inserting any content that already existed in the content attribute
%input{id: "#{dom_id(section, 'trix-editor')}", name: "#{dom_id(section, 'trix-editor')}", content: "#{section.content}", type: :hidden}
%trix-editor{input: "#{dom_id(section, 'trix-editor')}"}