Shaun Mccran

My digital playground

05
F
E
B
2011

JQuery scrolling within a Div

Ever wanted to have your page content scroll based on user interaction? In this article I'll show you how to create a simple JQuery scrollable area that will allow users to click on 'next' style links to view more information. I put this together as most of the JQuery scrolling articles out there deal with scrolling the entire page, but I just want to scroll inside a defined div element.

There is a demo of this here: JQuery scrolling within a Div

[ More ]

28
J
A
N
2011

Passing variables to js files inline

Ever wanted to pass a variables to a javascript file within the code?

You can declare JavaScript variables globally, but in this case a non technical person was editing the sites code base, so getting them to construct

JavaScript variables was going to be an issue. How about passing them through within the script tag?

[ More ]

11
J
A
N
2011

Google maps panning example

I've been tinkering with the Google Maps Api recently, in an effort to replicate a flash project I've seen. It was a Google maps interface that used Adobe livecycle (http://www.adobe.com/products/livecycle/) feeds to poll IP addresss and display them within the map interface.

I liked the look of it, but wanted to create it in JQuery as it required a lot of custom server side code, and several expensive server software installations. Also I'm migrating away from the flash / flex arena into a more purist JQuery / AJAX development mindset.

There is a full example of Google Maps panning here

[ More ]

08
D
E
C
2010

Differences in calling a function in JQuery

I'm still playing around with some aspects of JQuery, and I noticed recently that I was still writing functions in the old school JavaScript fashion. I was constructing a JQuery selector, and then pointing the event handler to a separate JavaScript function. Like this:

view plain print about
1$("#type").change(changeFields);
2
3function changeFields(){
4    var selected = $("#type option:selected").val();
5            $('.formElems').hide();
6            $("." +selected).show();
7            }

I noticed then that all the other JQuery based functions do not construct the function as a separate entity. The function is embedded within the actual event handler.

More like this:

view plain print about
1$("#type").change(function ()
2        {
3        var selected = $("#type option:selected").val();
4            $('.formElems').hide();
5            $("." +selected).show();
6        });

Both methods work equally as well (IE they do what they are supposed to) but I can't see any reason you would do one over the other. The only thing I can think of is that in the first example the function is reference able from elsewhere, whereas the second code example is not.

Anyone more knowledgeable than me got a view on this?

_UNKNOWNTRANSLATION_ /