link_to_remote_with_conditions
A very simple plugin that provides link_to_remote_if and link_to_remote_unless methods
Status: v1.0 (Rails 2.3.x)
Links: Download | Repository
Licence: MIT
Readme:
This plugin adds the ability to handle conditionals in link_to_remote calls. It
provides two methods:
- link_to_remote_if(condition, name, options = {}, html_options = nil)
- link_to_remote_unless(condition, name, options = {}, html_options = nil)
They works in the same manner that link_to_if and link_to_unless do; if the
supplied conditional is true, then it renders a link; if the supplied
conditional is false, then it simply renders the link's text.
Both methods support the same options as link_to_remote; they are simply
wrappers around it.
Code for these methods was taken from a patch submitted by Gumaro Melendez to
the Rails lighthouse issue tracker. You can find the original post here:
https://rails.lighthouseapp.com/projects/8994/tickets/511-link_to_remote_if-and-l
Example
=======
# Generates: <a href="#" onclick="new Ajax.Request('/do/something',
# {asynchronous:true, evalScripts:true}); return false;">
# This is a link</a>
link_to_remote_if true, 'This is a link', :url => do_something_path
# Generates: This is not a link
link_to_remote_unless true, 'This is not a link, :url => do_something_path
Copyright (c) 2010 Nicholas Firth-McCoy, released under the MIT licence
