Skip to content

Instantly share code, notes, and snippets.

@paneq
Created June 14, 2011 14:40
Show Gist options
  • Save paneq/1025029 to your computer and use it in GitHub Desktop.
Save paneq/1025029 to your computer and use it in GitHub Desktop.
Example
# app/controllers/bubbles_controller.rb
class BubblesController < ApplicationController
has_widgets do |root|
root << widget(:facebook)
end
end
#app/widgets/facebook/display.html.erb
<%= widget_div do %>
<%= rand %>
<h1 id="12">
FacebookWidget#display
</h1>
<p>
Find me in app/widgets/facebook/display.html.erb
</p>
<%= link_to "Submit", url_for_event(:submit), :remote => true %>
<% end %>
# app/widgets/facebook_widget.rb
class FacebookWidget < Apotomo::Widget
responds_to_event :submit, :with => :process_submit
def display
render
end
def process_submit(evt)
replace(:state => :display)
end
end
$("facebook").replace("<div id=facebook>0.14460199105946114<h1 id=12> FacebookWidget#displayh1><p> Find me in app/widgets/facebook/display.html.erbp><a href=/bubbles/render_event_response?source=facebook&amp;type=submit data-remote=true>Submita>div>");
#app/views/bubbles/index.html.erb
<%= render_widget :facebook %>
$("facebook").replace("<div id=\"facebook\">\n\n0.5280982822732676\n\n<h1 id=\"12\">\n FacebookWidget#display\n<\/h1>\n\n<p>\n Find me in app/widgets/facebook/display.html.erb\n<\/p>\n\n<a href=\"/bubbles/render_event_response?source=facebook&amp;type=submit\" data-remote=\"true\">Submit<\/a>\n\n<\/div>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment