Sha256: 282c2250541e1689b24617de2719ba6821a5fb25603bcb2a1d67f26c64d1c56c
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
module FaceboxRender def render_to_facebox( options = {} ) options[:template] = "#{controller_name}/#{action_name}.html.erb" if options.empty? #default action_string = render_to_string(:action => options[:action], :layout => false) if options[:action] template_string = render_to_string(:template => options[:template], :layout => false) if options[:template] render :update do |page| page << "jQuery.facebox(#{action_string.to_json})" if options[:action] page << "jQuery.facebox(#{template_string.to_json})" if options[:template] page << "jQuery.facebox(#{(render :partial => options[:partial]).to_json})" if options[:partial] page << "jQuery.facebox(#{options[:html].to_json})" if options[:html] if options[:msg] page << "jQuery('#facebox .content').prepend('<div class=\"message\">#{options[:msg]}</div>')" end yield(page) if block_given? end end # close an existed facebox, you can pass a block to update some messages def close_facebox render :update do |page| page << "jQuery.facebox.close();" yield(page) if block_given? end end # redirect_to other_path (i.e. reload page) def redirect_from_facebox(url) render :update do |page| page.redirect_to url end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facebox-render-0.9.0 | lib/facebox_render.rb |