Home  >  

jQuery FTW for April 3, 2009

Author photo
AddThis Social Bookmark Button

Once again, I'm entering my time machine to enter my 'weekly' report a bit late. Sorry! As always, here are the links/plugins/blog entries/etc from the jQuery world that I thought would be of interesting. Please email me at ray at camdenfamily dot com if you would like to submit something to share.

  • The first link is Fullsize. Technically I'm linking here because of it's jQuery plugin, but really this is almost a manifesto by the developer to convince the W3C to add a "fullsize" attribute to HTML. I'm with him on this one.
  • Next up is yet another gallery plugin: GalleryView. While there seem to be thousands of these, I really like how this plugin presents its list of images.
  • Useful and Handy jQuery Tips and Tricks - a blog entry covering a set of trick. The range here is pretty varied so be sure to skim the entire entry.
  • Select content from one list to another using jQuery - the title pretty much says it all, but it covered something I needed to work with this week so it came up just in time for me.
  • Another old blog entry, but another thing I needed during my development. This blog entry by Rick Strahl covers centering content using jQuery. Kinda surprised this isn't easier.

Read more from Raymond Camden. Raymond Camden's Atom feed cfjedimaster on Twitter

Comments

5 Comments

Travis Almand said:

"Kinda surprised this isn't easier."

I'm surprised it doesn't seem easy. To center with jQuery I just do this to an element:

$("#element").css({"position" : "fixed", "top" : ($(window).height() / 2) - ($("#element").height() / 2), "left": ($(document).width() - $("#element").width()) / 2});

This assumes that the element in question is on the page, sized to be a popup and is hidden on the page which is then shown at some point. My project code this is pulled from uses a fadein but I removed that for this post. Since the element is position fixed if you scroll it stays centered in the window. You would have to run the code again on a window resize though.

Is it exactly centered? Probably not but it's close enough that most people wouldn't notice.

This works for me on every browser I tried except for IE6. And the thing that fails on IE6 is the fixed position since it is not supported. For that I look for IE6 and apply a 100% height on the body/html tags with an absolute position on the element instead of fixed.

My project this code is from only has the one modal element so I suppose if a project required several I would make it a plugin or at least a function to avoid rewriting code.

Raymond Camden said:

"I'm surprised it doesn't seem easy."

Heh, well, I'm still learning. :)

Nice technique there, and it makes sense.

Anonymous said:

Reading back over my post it seems to me I was a bit harsh in the wording, I didn't mean for it to be that way.

The reason it seemed easy to me is because I transitioned from Actionscript to Javascript and doing things like that in Flash is common since you are usually directly controlling positions with code.

Reading back over my post again I notice my code only works for a popup style element and not centering in an element on the page. Although that should be much the same with using the parent element to grab height and width to center by instead of the window. I'll have to try that one.

Travis Almand said:

Wow, my credentials disappeared from my post.

I always seem to have hiccups with posting here. For instance, I always have to preview my post to get the captcha input to work. It never works for me from the article page.

Anyway, that post above, that's me.

Raymond Camden said:

No worries Travis. jQuery reminds me a lot of ColdFusion - there are numerous ways to solve the same problem.

+1 on the CAPTCHA. Next time I talk to the 'bosses' here I'll bring it up. I find it a bit hard to read too.

Leave a comment


Type the characters you see in the picture above.


Tag Cloud

Technical Speakers

Who is the best technical speaker you have seen?

Answer

Latest Features

Recommended for You

@InsideRIA on Twitter

Archives

  • Or, visit our complete archive.  

About This Site

Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.