Now takes an option to skip sisyphus processing.
This commit is contained in:
parent
810a02bece
commit
008eb76a9b
16
README.md
16
README.md
@ -23,11 +23,11 @@ For a basic install include the following in your *app/assets/javascripts/applic
|
|||||||
|
|
||||||
## How it Works
|
## How it Works
|
||||||
|
|
||||||
Sisyphus uses an aliased form_tag method to automatically put a *<script>...</script>* tag infront of your forms to initialize Sisyphus
|
Sisyphus uses an aliased form_tag method to automatically put a *<script>...</script>* tag infront of your forms to initialize Sisyphus. It also uses an aliased FormHelper form_for method to read options.
|
||||||
|
|
||||||
<script>$(document).ready(function() {$('#sampleform').sisyphus();});</script>
|
<script>$(document).ready(function() {$('#sampleform').sisyphus();});</script>
|
||||||
<form id="sampleform">
|
<form id="sampleform">
|
||||||
...
|
...
|
||||||
</form>
|
</form>
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -35,6 +35,11 @@ Sisyphus automatically works with all your forms, including custom form builders
|
|||||||
|
|
||||||
### Exclude form
|
### Exclude form
|
||||||
|
|
||||||
|
To stop Sisyphus from initializing on a form include the *with_sisyphus* option in your form_for.
|
||||||
|
|
||||||
|
<%= form_for User.new, :with_sisyphus=>false do |f| %>
|
||||||
|
...
|
||||||
|
<% end %>
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
@ -44,8 +49,13 @@ Sisyphus automatically works with all your forms, including custom form builders
|
|||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- Tests
|
- Tests
|
||||||
- Multiple library support for jStorage (Prototype, Mootools etc.)
|
|
||||||
- Model/Object based exclusions
|
- Model/Object based exclusions
|
||||||
|
- block based options
|
||||||
|
|
||||||
|
<%= form_for User.new do |f| %>
|
||||||
|
<% :sisyphus => flase %>
|
||||||
|
...
|
||||||
|
<% end %>
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
require "sisyphus-rails/version"
|
require "sisyphus-rails/version"
|
||||||
require "sisyphus-rails/engine"
|
require "sisyphus-rails/engine"
|
||||||
# require "sisyphus-rails/form_helper"
|
require "sisyphus-rails/form_helper"
|
||||||
require "sisyphus-rails/form_tag_helper"
|
require "sisyphus-rails/form_tag_helper"
|
||||||
|
|
||||||
module Sisyphus
|
module Sisyphus
|
||||||
|
mattr_accessor :process
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# if defined?(ActionView::Base)
|
|
||||||
# ActionView::Base.default_form_builder = Sisyphus::FormBuilder
|
|
||||||
# end
|
|
19
lib/sisyphus-rails/form_helper.rb
Normal file
19
lib/sisyphus-rails/form_helper.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
module ActionView
|
||||||
|
module Helpers
|
||||||
|
module FormHelper
|
||||||
|
def form_for_with_sisyphus(record, options = {}, &proc)
|
||||||
|
|
||||||
|
if options[:with_sisyphus] == false
|
||||||
|
Sisyphus::process = false
|
||||||
|
else
|
||||||
|
Sisyphus::process = true
|
||||||
|
end
|
||||||
|
|
||||||
|
#strip all the sisyphus options from the options hash before moving on
|
||||||
|
form_for_without_sisyphus(record, options.reject{|k,v| k =~ /sisyphus(.*)/}, &proc)
|
||||||
|
end
|
||||||
|
|
||||||
|
alias_method_chain :form_for, :sisyphus
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -5,7 +5,7 @@ module ActionView
|
|||||||
def form_tag_with_sisyphus(url_for_options = {}, options = {}, &block)
|
def form_tag_with_sisyphus(url_for_options = {}, options = {}, &block)
|
||||||
buf = ActiveSupport::SafeBuffer.new
|
buf = ActiveSupport::SafeBuffer.new
|
||||||
|
|
||||||
if options.has_key?(:id)
|
if options.has_key?(:id) && Sisyphus::process
|
||||||
buf.safe_concat("<script type=\"text/javascript\">$(document).ready(function() {$('##{options[:id]}').sisyphus();});</script>")
|
buf.safe_concat("<script type=\"text/javascript\">$(document).ready(function() {$('##{options[:id]}').sisyphus();});</script>")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user