This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 11810c2467fd3455001bf59a7ed2bec338c064c7
tree 317d659292ba0f5f4fb7533059a72207dc870b0f
parent 547813f65b22ff1cef04a86e7563159308a64eeb
tree 317d659292ba0f5f4fb7533059a72207dc870b0f
parent 547813f65b22ff1cef04a86e7563159308a64eeb
| name | age | message | |
|---|---|---|---|
| |
CHANGES | ||
| |
MIT-LICENSE | ||
| |
README.markdown | ||
| |
Rakefile | ||
| |
about.yml | ||
| |
init.rb | ||
| |
lib/ | ||
| |
public/ | ||
| |
tasks/ | ||
| |
test/ |
README.markdown
ActionButton
This provides helpers for creating a non-AJAX form containing a single button element. Using a button element allows the actions to be safe, not javascript dependent, and easily styled.
This plugin also includes a custom version of the lowpro javascript library, and a helper for adding a unobtrusive javascript snippet to handle AJAX form submission of the button.
Methods and Options
button_tag (name, content, type, html_options)name: the name and id attribute of the buttoncontent: the content inside the open/close tagstype:submit,reset, orbutton
action_button (name, content, url_for_options, options)name: the name and id attribute of the buttoncontent: the content inside the button open/close tagsurl_for_options: same as forlink_to, andform_for, etc.options:- accepts all normal HTML options that are generally available on
content_tag :wrapper_tag- this takes a symbol for the tag name to be used around the buttondefault is `:p`:form_class- set's the class attribute for the form tag:form_id- set's the id attribute for the form tag:wrapper_class- set's the class for the wrapper tag. default:nil
- accepts all normal HTML options that are generally available on
lowpro_remote_form (selector, options)selector: the CSS selector used to specify which element(s) to apply this observer to.options:- all the standard
options_for_ajaxoptions used in all theremotePrototype helpers :confirm- presents the user with a confirm dialog before submitting form:update- can either be a single DOM ID specifying which element to updateor a hash of `:success` and `:failure` to update different elements based on the AJAX result.
- all the standard
Examples
Create a delete button:
action_button 'delete-comment', 'Delete this Comment', comment_path(@post, comment), {:method => :delete, :number => comment.id}
Produces:
<form action="/posts/5/comments/12" class="delete-comment-form" id="delete-comment12-form" method="post">
<div style="margin:0;padding:0">
<input name="_method" type="hidden" value="delete" />
</div>
<p>
<button class="delete-comment" id="delete-comment12" name="delete-comment12" type="submit">Delete this Comment</button>
</p>
</form>
Embed an image and use custom classes and id for easier styling:
action_button 'delete-comment', image_tag('icons/delete.png', :alt => 'Add a Comment'),
new_comment_path(@post),
{ :id => "commentDel", :class => 'delComment',
:form_class => 'delComment', :form_id => "delCommentForm" }
Produces:
<form action="/posts/5/comments/12" class="delComment" id="delCommentForm12" method="post">
<div style="margin:0;padding:0">
<input name="_method" type="hidden" value="delete" />
</div>
<p>
<button class="delComment" id="delComment12" name="delComment12" type="submit">
<img src="/images/icons/delete.png" alt="Delete this Comment" />
</button>
</p>
</form>
License
Copyright (c) 2008 Brian Landau of Viget Labs, released under the MIT license








