Module: Zena::Use::HtmlTags::LinkTags

Includes:
WillPaginate::ViewHelpers
Included in:
ViewMethods
Defined in:
lib/zena/use/html_tags.rb

Overview

FormTags

Instance Method Summary collapse

Instance Method Details

unobtrusive link_to_remote



143
144
145
146
# File 'lib/zena/use/html_tags.rb', line 143

def link_to_remote(name, options = {}, html_options = {})
  html_options.merge!({:href => url_for(options[:url])}) unless options[:url].blank?
  super(name, options, html_options)
end

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, options = *args
  options ||= {}
  if request.path == url
    options[:class] = 'on'
  end
  link_to(title, url, options)
end

#protect_against_forgery?Boolean

Returns:

  • (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(options = {}, html_options = {})
  url = url_for(options[:url])
  res = "<a href='#{url}' onclick=\"new Ajax.Request('#{url}', {asynchronous:true, evalScripts:true, method:'#{options[:method] || 'get'}'}); return false;\""
  html_options.each do |k,v|
    next unless [:class, :id, :style, :rel, :onclick].include?(k)
    res << " #{k}='#{v}'"
  end
  res << ">"
  res
end