[Rails] Re: Jquery to center: Form with multiple hidden divs -- JS will size to the smallest div....
Ruby on Rails
Tuesday, May 5, 2015
I mis-wrote my site url: www.echomarket.org
On Tuesday, May 5, 2015 at 12:49:05 PM UTC-4, Elizabeth McGurty wrote:
-- On Tuesday, May 5, 2015 at 12:49:05 PM UTC-4, Elizabeth McGurty wrote:
On my site I guess I have about 20 forms, four of which have multiple hidden divs within the forms of varying sizes.
For all of my forms the following works, but for those with the multiple divs... it sizes height to the smallest div. What should I do? Should I JS code specifically for those forms on load of the divs to manage height, or is there something in my JS that I am not aware and should use.... AND, of course, if there is a gem to manage centering I would love to learn about it. The point in centering, is that I want the width of my pages to be centered and nicely bordered despite browser.... I realize and am sure that you folks may have excellent alternatives, I would like to know what you have used.
$(document).ready(function() {
$.fn.center = function() {
var element = $(this);
var e_width = element.width();
var win_width = $(window).width();
var left_margin_calc = (win_width - e_width) / 2;
element.css('margin-left', (left_margin_calc + "px"));
};
$.fn.center_form = function() {
var element = $(this);
var e_width = element.width();
var win_width = $("div.form_wrapper").width();
var left_margin_calc = (win_width - e_width) / 2;
element.css('margin-left', (left_margin_calc + "px"));
var div_height = $("div.form_wrapper").height();
element.css("height", div_height);
element.css('border', '2px solid #4A572B');
};
$("div.form_wrapper").center();
$("form").center_form();
});
Thanks,
Liz McGurty
www.ecomarket.org
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/079cefd9-6547-4956-9b0d-0746543c6f1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment