Created
October 19, 2011 13:46
-
-
Save Bodacious/1298321 to your computer and use it in GitHub Desktop.
jQuery Mobile Popup Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
# call this method in the view | |
# name should be a unique ID for this page, condition should be either truthy or falsey | |
def show_dialog_if(name, condition) | |
if condition | |
content = | |
link_to("click", "##{name}", | |
id: "#{name}_popup", class: "hidden", | |
data: {rel: "dialog", theme: "a"}) | |
content += content_tag(:script, "jQuery(function(){$('##{name}_popup').trigger('click');})", type: "text/javascript") | |
content.html_safe | |
end | |
end | |
# call this in application.html (not ideal) for every message you'd like to display | |
def ajax_page(id, &block) | |
content = capture(&block) | |
%{ | |
<div data-role="page" id="#{id}"> | |
<div data-role="header" data-theme="b"></div> | |
<div data-role="content" data-theme="b"> | |
#{content} | |
</div> | |
<div data-role="footer" data-theme="b"></div> | |
</div> | |
}.html_safe | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment