jQuery in Action
Using other libraries with jQuery
163
Under the
W3C
box model, the size of the content of the element is 180 by 72 pix-
els exactly as specified by the
width
and
height
values. The padding and the bor-
der are applied outside this 180 by 72 pixel box, resulting in a total footprint of
210 by 102 pixels for the entire element.
210 by 102 pixels for the entire element.
When the traditional box model is used, the entire element is rendered in the
180 by 72 pixel box defined by the
width
and
height
attributes, reducing the size
of the content to 150 by 42 pixels.
There are those on both sides of the fence that claim that one of these mod-
els is more intuitive or correct than the other, but the fact is we have to live with
the difference.
the difference.
If our code needs to account for these differences in that way that the elements
will be rendered, the
$.boxModel
flag lets us know which is in force, and we can
make our computations accordingly.
6.1.3 Detecting the correct float style to use
One other difference in browser capabilities that jQuery provides a flag for is
the name used to represent the
the name used to represent the
float
CSS
style in the element's
style
property.
This flag,
$.styleFloat
, evaluates to the string that should be used for the prop-
erty name.
For example, to set the
float
value for an element, we use
element.style[$.styleFloat] = 'left';
This will account for any browser differences between the naming of this prop-
erty--this flag evaluates to
erty--this flag evaluates to
styleFloat
for Internet Explorer and to
cssFloat
for
other browsers.
NOTE
This flag is generally not required for on-page use. The
css()
wrapper
method, when used with float, chooses the correct property (using this
flag). The authors of plugins and other extensions are the target users of
this flag for those cases where lower-level control is essential.
flag). The authors of plugins and other extensions are the target users of
this flag for those cases where lower-level control is essential.
Now let's leave the world of flags and look at the utility functions that jQuery
provides.
provides.
6.2 Using other libraries with jQuery
Back in section 1.3.6, we introduced a means, thoughtfully provided for us by
the jQuery team, to easily use jQuery on the same page as other libraries. Usually,
the jQuery team, to easily use jQuery on the same page as other libraries. Usually,