Shaun Mccran

My digital playground

13
A
P
R
2011

Triggering functions when closing a fancybox pop up

The FancyBox JQuery plugin is a popular lightbox style plugin that allows you a variety of options to 'pop' different types of content up into a users view.

I needed to have the parent page change when the user had performed an action within the pop up. But how to do this?

FancyBox (http://fancybox.net/) has a 'onClosed' option to allow you to embed a function call whenever the user closes the lightbox.

The format of this is a little tricky, so here is an example:

view plain print about
1// pop up handler
2$.fancybox({
3    'autoDimensions':    false,
4    'speedIn'            : 600,
5    'speedOut'            : 200,
6    'overlayShow'        : true,
7    'width'            : 440,
8    'height'            : 340,
9    'type'            : 'iframe',
10    'scrolling'            : 'no',
11    'transitionIn'        : 'elastic',
12    'transitionOut'        : 'fade',
13    'enableEscapeButton'    : 'true',
14    'overlayOpacity'        : 0.5,
15    'title'            : '',
16    'href'             : 'yourpage.htm',
17    'onClosed'            : function() { alert('closed'); }

You can build any function you want in this call, it is normal JavaScript after all, if you just wanted to reload the page you could have a refresh function:

view plain print about
1function() {
2
3parent.location.reload(true);
4
5}

This seems to work for any method of closing the Fancybox as well, so it will always fire.

24
M
A
R
2011

JQuery Drag and Drop to multiple div elements

My only previous experience with Drag and Drop web development was with Flex 2, which I have to say was a bit of a nightmare. There was an astronomical amount of setup to do in terms of event listeners and mouse watching services, so I was reluctant to get back into 'Drag and Drop' with any other technology.

This article explains how straight forward the JQuery Drag and Drop interfaces are to use, and how I constructed a Drag and Drop example using multiple divs.

There is an example of a JQuery Drag and Drop demo here. http://www.mccran.co.uk/examples/jquery-drag-drop

[ More ]

22
M
A
R
2011

Book review: CMS Design Using PHP and JQuery

I was recently approached by Packt Publishing to review one of their new books, CMS Design using PHP and JQuery. They mentioned that I'm always talking about JQuery so thought I'd be an ideal test subject.

I've dabbled in some PHP, and JQuery is an everyday tool in my arsenal so I was more than happy to give it a read.

[ More ]

27
F
E
B
2011

Using the JQuery Tooltip plugin to enhance title attributes

The title tag attribute is a modern staple of any developers html code base. Most of us use them, more of us should use them more. I've learnt more recently that they have wider implications for Accessibility users, but I've also come to change my thinking of their use.

This article shows how you can use the JQuery tooltip plugin to enhance the title attribute, and how the title tag can be used to convey a more useful message to your browsers.

[ More ]

_UNKNOWNTRANSLATION_ /