Module: Zena::Use::HtmlTags::LinkTags
Overview
FormTags
Instance Method Summary collapse
-
#link_to_remote(name, options = {}, html_options = {}) ⇒ Object
unobtrusive link_to_remote.
-
#link_to_with_state(*args) ⇒ Object
Add class=‘on’ if the link points to the current page.
- #protect_against_forgery? ⇒ Boolean
-
#tag_to_remote(options = {}, html_options = {}) ⇒ Object
only display first <a> tag.
Instance Method Details
#link_to_remote(name, options = {}, html_options = {}) ⇒ Object
unobtrusive link_to_remote
143 144 145 146 |
# File 'lib/zena/use/html_tags.rb', line 143 def link_to_remote(name, = {}, = {}) .merge!({:href => url_for([:url])}) unless [:url].blank? super(name, , ) end |
#link_to_with_state(*args) ⇒ Object
Add class=‘on’ if the link points to the current page
133 134 135 136 137 138 139 140 |
# File 'lib/zena/use/html_tags.rb', line 133 def link_to_with_state(*args) title, url, = *args ||= {} if request.path == url [:class] = 'on' end link_to(title, url, ) end |
#protect_against_forgery? ⇒ Boolean
128 129 130 |
# File 'lib/zena/use/html_tags.rb', line 128 def protect_against_forgery? false end |
#tag_to_remote(options = {}, html_options = {}) ⇒ Object
only display first <a> tag
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/zena/use/html_tags.rb', line 149 def tag_to_remote( = {}, = {}) url = url_for([:url]) res = "<a href='#{url}' onclick=\"new Ajax.Request('#{url}', {asynchronous:true, evalScripts:true, method:'#{[:method] || 'get'}'}); return false;\"" .each do |k,v| next unless [:class, :id, :style, :rel, :onclick].include?(k) res << " #{k}='#{v}'" end res << ">" res end |