Added a default form builder.
The form builder has a bug, it's initialize is called twice so we need to find a better place to put the <script... adding code.
This commit is contained in:
parent
2c9ea67146
commit
f39a2f1422
@ -34,6 +34,7 @@ ActionView::Base.default_form_builder = YourFormBuilder
|
|||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
|
- Fix the double script tag issue caused by the initialization of the builder twice, once in form_for and once in fields_for right below it
|
||||||
- Tests
|
- Tests
|
||||||
- Multiple library support for jStorage (Prototype, Mootools etc.)
|
- Multiple library support for jStorage (Prototype, Mootools etc.)
|
||||||
- Support for formtastic and extending other form builders
|
- Support for formtastic and extending other form builders
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
require "sisyphus-rails/version"
|
require "sisyphus-rails/version"
|
||||||
|
require "sisyphus-rails/engine"
|
||||||
|
require "sisyphus-rails/form_helper"
|
||||||
|
|
||||||
module Sisyphus
|
module Sisyphus
|
||||||
module Rails
|
|
||||||
class Engine < ::Rails::Engine
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if defined?(ActionView::Base)
|
||||||
|
ActionView::Base.default_form_builder = Sisyphus::FormBuilder
|
||||||
|
end
|
4
lib/sisyphus-rails/engine.rb
Normal file
4
lib/sisyphus-rails/engine.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
module Sisyphus
|
||||||
|
class Engine < ::Rails::Engine
|
||||||
|
end
|
||||||
|
end
|
8
lib/sisyphus-rails/form_helper.rb
Normal file
8
lib/sisyphus-rails/form_helper.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module Sisyphus
|
||||||
|
class FormBuilder < ActionView::Helpers::FormBuilder
|
||||||
|
def initialize(object_name, object, template, options, block=nil)
|
||||||
|
super
|
||||||
|
@template.output_buffer << "<script type=\"text/javascript\">$(document).ready(function() {$('##{self.options[:html][:id]}').sisyphus();});</script>".html_safe
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,7 +1,7 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
lib = File.expand_path('../lib', __FILE__)
|
lib = File.expand_path('../lib', __FILE__)
|
||||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||||
require 'sisyphus/rails/version'
|
require 'sisyphus-rails/version'
|
||||||
|
|
||||||
Gem::Specification.new do |gem|
|
Gem::Specification.new do |gem|
|
||||||
gem.name = "sisyphus-rails"
|
gem.name = "sisyphus-rails"
|
||||||
|
Loading…
Reference in New Issue
Block a user