Created
March 4, 2012 18:32
-
-
Save ncherro/1974301 to your computer and use it in GitHub Desktop.
monkeypatch to Twitter Bootstrapify the Nested Form add / remove buttons
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
# put this in in config/initializers | |
require 'nested_form/builder_mixin' | |
module NestedForm | |
module BuilderMixin | |
alias_method :link_to_add_original, :link_to_add | |
alias_method :link_to_remove_original, :link_to_remove | |
def link_to_add(*args, &block) | |
options = args.extract_options!.symbolize_keys | |
options[:class] = [options[:class], 'btn'].compact.join(' ') | |
link_to_add_original *args, options, &block | |
end | |
def link_to_remove(*args, &block) | |
options = args.extract_options!.symbolize_keys | |
options[:class] = [options[:class], 'btn btn-danger'].compact.join(' ') | |
link_to_remove_original "<i class=\"icon-trash icon-white\"></i> #{args.first}".html_safe, options, &block | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment