You are here

JQuery and JQueryUI - The undocumented feature(s)

In the first post of the summer, I'm going to reveal a few interesting features that exist in jQuery and jQueryUI, which I've been using quite extensively recently.

The first of these features is jQueryUI's dialogs and the "position" attribute.

The jQueryUI docs say:

Specifies where the dialog should be displayed. Possible values:
1) a single string representing position within viewport: 'center', 'left', 'right', 'top', 'bottom'.
2) an array containing an x,y coordinate pair in pixel offset from left, top corner of viewport (e.g. [350,100])
3) an array containing x,y position string values (e.g. ['right','top'] for top right corner).

However, there's a fourth undocumented value. That is a combination of options 2 and 3.

That's to say, you can say ['right', 20] to position 20 pixels away from the top of the browser viewpane, and all the way to the right.

Sadly, there's no ['right' - 20, 20] to give a 20 pixel margin around the dialog.

Another useful, but documented, feature of jQuery is the multi-selector.

The following snippet of code comes from a form parser:

var children = $("#" + id).children("input,select,textarea");

It selects all input, select and textarea elements within the element with the ID specified by "id".

Hopefully these have helped you, and good luck with your jQuerification quest.

Blogs: 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer