Sha256: 6fac5359c8113b289166048bc4a50129cd9b5dea9a6ac30f705e4b85e3f97b32
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
module DynamicMenu class ActionMenuItem include ActionView::Helpers::UrlHelper include ActionView::Helpers::JavaScriptHelper attr_accessor :name, :link, :method, :link_tag def initialize(name, link , method = :get, confirm="Are You Sure?") @name = name @link = link @method = method @link_tag = "" if method == :delete @link_tag = link_to name, link, :method=>method, :confirm=>confirm else if link == :submit #make it easy to include a submit button via link...for enter support...requires #JQUERY!!! @link_tag = link_to_function name, "$('form').submit()" @link_tag += "<script type=\"text/javascript\"> $(document).ready(function(){ $('html').keypress(function(e){ if(e.which == 13){ $('form').submit(); return false; } }); });</script>".html_safe elsif link == :back @link_tag = "<a href=\"#\" id=\"jcheats-back\">#{name}</a>".html_safe @link_tag += "<script type=\"text/javascript\"> $(\"#jcheats-back\").live(\"click\", function(){ var ref = document.referrer; document.location=ref; }); </script>".html_safe else @link_tag = link_to name, link end #end if submit end #end if delete end #end initalize end #end actionmenu Item end #end Modlue
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dynamic_menu-0.2.3 | lib/dynamic_menu.rb |