Modal Dialog form in Rails using jQuery
I have a rails form with form_tag for subscriptions. I want to redirect to this page from my home page, as a Modal Dialog Form, if a user is visiting my website for开发者_开发百科 the first time. Here is my rails form code snippet:
<% title "New Profile" %>
<div id="whatwe-do">
<div class="close-button">
Close
</div>
<%= form_tag '/subscriptions', :id => 'new_subscription' do%>
<div id="subscription_dialog">
<div style="margin: 0pt; padding: 0pt; display: inline;">
<input type="hidden" value="✓" name="utf8">
<input type="hidden" value="jChrjugvuBT9cq9D5J1eWKq2GehRpuGCN6OkLEVXunw=" name="authenticity_token">
</div>
<div class="category-wrapper">
<div class="category">
<% for category in @categories %>
<strong><%= category.name %></strong>
<% for sub_category in category.sub_categories%>
<div class="items">
<%= check_box_tag "profile[user_interest_ids][]", sub_category.id,
@profile.get_user_interests.include?(sub_category.id) %>
<%= sub_category.name %>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
<div id="email-wrapper">
<%= text_field_tag :email %>
<%= submit_tag "Send me Deals" %>
</div>
<% end %>
And here's my jQuery script:
$("#subscription_dialog").dialog({modal:true, width:'auto', height:'auto'});
I tried this too:
$("#new_subscription").dialog({modal:true, width:'auto', height:'auto'});
None of these seem to work. Can anyone suggest my how to do a modal dialog form in Rails using jQuery? Thanks.
you made sure that the dom was loaded?
$(function(){
$("#subscription_dialog").dialog({modal:true, width:'auto', height:'auto'});
})
精彩评论