Accordion height
autoHeight feature, 535
div elements, 533
extra-high content element, 534
img elements, 532
incorrect height problems, 533
large height difference, 534–535
resizing, 536
style element, 533
active swatch, 799
activePage property, 785
additionalflowers.json, 439
Ajax
advanced configuration settings
data conversion, 426
JSON.stringify method, 425
synchronous request, 421
asynchronous requests, 372
basic request configuration settings, 417
callback functions, 372
default settings, 427
events handling
beforeSend setting, 411
context setting, 413
event settings, 406
multiple event handling functions, 412
expected data type specifying, 388–390
GET request
button press response, 376–377
class attribute, 374
example document, 373
example.html, 373
HTML fragment, 374
inline data, 376
load, getScript, and getJSON methods, 379
mydata.json, 377
preventDefault method, 377
response data processing, 375–376
slice and appendTo method, 378
cross-origin Ajax requests, 382–383
formserver.js, 381
total property, 382
type-specific convenience methods
URL setting, 404
ajaxSetup method, 428–439, 442
ajaxStart and ajaxStop methods, 414
Android SDK emulator, 755
Apple Safari browser, 753
attr method, 785
autoOpen setting, 720
background-color properties, 58
basket elements, 716
bind method, 770
boolean values, 95
border property, 62
Border style, 65
Border width, 65
Browser event shorthand methods, 243–244
bubbles property, 35
button method, 474
Button widgets
automatic creation
configuration
data attributes, 808
buttonDiv element, 716
cancelable property, 35
Carousel event handler functions, 285–287
Cascading Style Sheets (CSS), 37
embedded style
anatomy, 41
attribute, 40
effect, 42
head element, 41
h2 element, 41
h1 selector, 43
selectors, 41
HTML document, 37
selectors
core selectors, 45
pseudo-element and pseudo-class selectors, 49–51
shorthand properties and custom values, 64–66
style cascading
author styles, 54
color property, 54
embedded styles, 53
external styles, 53
inline styles, 53
specificity and order assessments, 55–58
tweaking, important styles, 54–55
units
absolute lengths, 60
font-size property, 60
percentages, 64
properties and values, 58
changePage method, 778–779, 797
bind method, 779
transition effect direction, 780–782
ui-grid-a, ui-block-a, and ui-block-b classes, 779
children method, 156
class attribute, 46
Client-side validation, 338
Collapsible content blocks
collapse and expand events, 821–823
data attributes, 818
single collapsible block
expansion, 818
color property, 119
Content distribution networks (CDNs), 102, 474–475, 730
Content elements
elements with external resources, 25–26
semantic/presentation divide, 21–23
structural elements, 25
countImgElements function, 107
Cross-Origin Resource Sharing (CORS), 383
cycleEffects function, 270
Data templates
conditional templates
conditional statements, 315
flowerTmpl template, 312
{{if}} and {{/if}} tags, 311
in-stock items, 313
stocklevel property, 312
template rendering, 313
first data templates example
appendTo method, 299
div elements, 299
expressions evaluation, 302–303
flower data definition, 298
inline data, 297
remote data, 297
script element, 296
tmpl method, 299
iteration control
{{each}} template tag, 315–316
$index variable, 316
$value variable, 316
jQuery templates library, 295–296
manipulation
flowerTmpl template, 321
handleMouse function, 321, 323
mouseenter method, 321
template item object properties, 322
tmpl property, 322
update method, 323
data formatting, 311
flowerTmpl, 308
inline data refactoring, 310–311
inputTmpl template, 308
rowid, 310
rowTmpl template, 310
{{tmpl}} tag, 309
template variables
data variable, 304
discount property, 307
stockDisplay function, 307
data-ajax attribute, 830
dataFilters, 462
data-native-menu attribute, 840
data-overlay-theme attribute, 840
data-placeholder attribute, 841
data-theme attribute, 799, 800
dayOfWeek object, 79
dcell class, 48
defaultPrevented property, 35
Deferred objects, 939
callbacks with long-lived task, 942–943
chaining method, 953
click handler function, 961
click method, 941
$.Deferred method, 941
definition, 939
displayMessage function, 941
for loop, 951
performLongTask function, 943–945
Deferred objects (cont.)
registering callbacks, 949
resolve method, 942
setTimeout function, 944, 945, 961
table element, 941
then method, 953
dialog method, 719
doAnimation function, 268
Document event shorthand methods, 243
Document Object Model (DOM), 153
child and descendant elements insertion
methods, 158
wrapInner method, 159
$(document).ready approach, 107
document variable, 106
element creation
elements removal
using selector, 181
getElementsByTagName method, 31
HTMLElement properties, 29
img elements, 31
JavaScript, 29
navigation
across the hierarchy, 147
children and find methods, 138–139
down the hierarchy, 138
first matching ancestor (see First matching ancestor)
intersection creation, 140
nextAll and prevAll methods, 149–150
overlapping descendants, 139
siblings method, 148
up the hierarchy, 141
objects
events handling, 121
function, 116
multiple elements and chaining method, 118–120
parent and ancestor elements insertion
dynamic wrapping, 173
programming language, 27
ready method, 106
replacing elements
replaceWith and replaceAll methods, 178–179
sibling elements insertion
before and after methods, 175–176
insertAfter and insertBefore methods, 176
with function, 177
tagName and src properties, 31
document2.html file, 786
document2.html page, 790
document.querySelectorAll method, 120
Drag and drop tuning
accept setting, 664
grouping draggable and droppable elements, 666
helper element
draggable and droppable elements, 667
helper function and uses, 668
large draggable element, 666–667
manipulation, 669
over and out events, 669
property, 669
setting, 668
snapMode setting, 671
snapTolerance setting, 671
ui.helper property, 669
Draggable interaction
browser window, 643
configuration
delay and distance settings, 649–650
start and stop events, 651–652
HTML and CSS, 643
Droppable interaction
activate and deactivate events, 654–655
activeClass and hoverClass settings, 659–660
basic element, 653
drag and drop, 654
events, 652
fit and touch settings, 661–662
fit and touch values, 662
text method, 654
tolerance values, 661
Element selection, 123
DOM navigation (see Element selection:Document Object Model, navigation)
filter method, 127
reduction
Event handling
border and opacity properties, 226
CSS border property, 229
default action suppressing, 230–231
Event.data property, 229
event handler function removing, 231–233
jQuery event object members, 226–227
methods, 224
mouseenter and mouseout events, 226
one method, 233
event setting, 538
Event shorthand methods
bind method, 242
browser event shorthand methods, 243–244
document event shorthand methods, 243
form event shorthand methods, 245
function argument, 241
keyboard event shorthand methods, 246
mouse event shorthand methods, 244–245
Example document
additional flower products adding, 279–280
carousel buttons adding, 281–283
carousel event handler functions, 285–287
JavaScript disabling, 290
product selection total, 288–289
Extended colors, 59
fade effect, 770
fieldcontainer, 832
fieldcontrol div elements, 835
fieldset element, 847
fillSpace setting, 536
Firefox Mobile Emulator, 756–757
First matching ancestor
closest method, 144
closest method with reference objects, 145
closest positioned ancestor, 145, 146
flip effect, 768
Floating-point numbers, 73
font-size property, 119
Form event shorthand methods, 245
formserver.js, 436
get method, 442
getElementsByTagName, 120
header and headerSelected properties, 541
height property, 62
HTML, 13
attributes
class attribute, 17
name and value, 16
snowdrop, 16
document structure
basic structure, 18
DOCTYPE element, 18
elements with external resources, 25–26
script element, 20
semantic/presentation divide, 21–23
structural elements, 25
style element, 21
DOM (see Document Object Model)
element anatomy, 15
element content, 17
element hierarchy
ancestor-descendant relationships, 28
body element, 26
parent-child relationships, 27
parts, 27
sibling relationships, 28
jQuery form-event methods, 332
value changes, 335
form values validation
addClassRules method, 345
additional-methods.js, 344
attribute and name validation, 353–356
custom check creation, 358–361
element name attribute, 351–352
form validation plugin, 338–340
max check, 350
per-element validation, 356–357
remote validation, 344
Rose product, 346
stocklevel property, 350
validate method, 341
validation error display, 361–364
node.js server
action attribute, 330
input elements, 331
JavaScript, 328
Place Order button, 331
response, 332
server-side script, 328
void elements, 18
HTML5, 340
HTML5 data attributes, 220–221
HTMLElement object, 112
id attribute, 46
img elements, 107
Individual border properties, 66
insertAfter and insertBefore methods, 176
Integer, 73
Interaction state classes, 934–935
iPhone, 752
JavaScript, 67
arrays
contents reading and modification, 89–90
contentsenumeration, 90
creation and population, 88
myArray, 88
new Array(), 88
external script, 67
functions
code block, 70
return results, 71
Google Chrome console, 68
object
literals, 75
properties reading and modification, 76–77
property determination, 80
operators, 80
equality vs. identity operator, 82–85
numbers to strings conversion, 86–87
string concatentation, 85
strings to numbers conversion, 87–88
syntax and style, 68
undefined and null values, 93–96
variables and types
Booleans, 73
local and global variables, 72
strings, 73
animations, enabling and disabling, 275–276
arbitrary element data, 218–219
attributes and properties, 188
attr method, 188
attribute value, reading, 189–190
attribute value, setting, 190–191
attribute values with function, 193
HTMLElement object, 190
img elements, 190
output, 190
removeAttr method, 194
src attribute, 190
basic effects methods, 248
CDN, 102
classes
addClass method, 196
blueBorder class, 196
border property, 201
doToggle, 200
hasClass method, 196
img elements, 196
multiple classes toggling, 202
output, 197
preventDefault method, 200
removeClass method, 196
style declaration matching, 201
style element, 196
CSS
font-size property, 207
method, 206
multiple properties, setting, 207–208
property values setting, 209, 210
property-specific convenience method, 210–212
relative values setting, 208, 209
style attribute, 206
custom effects
absolute target property values, 265–266
form element, 265
height and width properties, 265
relative target property values, 266–267
jQuery, custom effects (cont.)
z-index property, 265
data and Ajax, 4
dcell class, 250
DOM, 3 (see also Document Object Model)
effect queue
creation, 267
cycleEffects function, 268
methods, 267
stopping and clearing, 270–272
element content
div.dcell selector, 213
methods, 213
text method, 213
element selection
img elements, 109
narrowing with context, 111–112
odd img elements, 109
odd pseudo-selector, 109
element visibility animation, 253–255
example code, 7
fade effects, 260
fadeOut, fadeIn, and fadeToggle methods, 261
showing and hiding elements, 261
hide element, 250
HTML editor, 9
image attribution, 11
JavaScript and CSS, 4
looping effects, 257
partial listing, 7
plugins, 4
selection result
selector property, 113
setting up
flower shop example document, 100–101
jQuery-1.7.js, 101
jquery.1.7.min.js, 101
styles.css, 101
show and hide methods, 249–250
:visible and :hidden selectors, 251
web browser, 9
web server, 9
jQuery Ajax event methods, 414
A-grade support, 732
automatic enhancement
custom JavaScript, 735
Opera Mobile browser emulator, 733
resolution, 733
script element, 732
body element, 731
CDNs, 730
check boxes
checkout process implementation, 894–899
data-ajax attribute, 830
device orientation changes
dialogs
programmatic closing and opening, 796–798
example.html contents, 731
form element and form-related child elements, 829
guidelines, 827
jquery-1.6.4.js file, 730
jquery.mobile-1.0.zip, 730
labels
div element, 830
fieldcontain, 830
fieldcontain cutoff point, 831–833
portrait orientation, 830, 831
link element, 731
list widgets (see List widgets)
meta element, 731
mobile devices
Android emulator, 755
avoiding bad assumptions, 751–753
desktop browsers, 759
Firefox Mobile emulator, 756–757
identification, 751
iPhone emulator, 755
Multi-Browser Viewer, 757, 758
Opera mobile emulator, 756
two cardinal sins, 751
unrealistic simulation and testing, 753–755
Windows Phone 7 emulator, 758–759
pages (see Pages and navigation)
programmatic product insertion
JavaScript code, 879
list items and pages, 880
quantity changes
range slider addition, 887–890
script elements, 731
custom selection menus, 839–840
data attributes, 839
placeholder elements, 841
programmatic menus control, 842–843
shopping basket
simple basket, 886
text input and textarea, 829
themes
creation, 730
ThemeRoller application, 798
touch events
mousedown event, 741
mouseup event, 741
standard, 739
and synthesized mouse events, 739–741
touchend event, 741
touchstart event, 741
jQuery UI, 469
accordion widgets
active header selection, 538–541
event type, 538
height (see Accordion height)
settings, 532
autocomplete widgets
configuration methods, 522–525
default select action, 527–528
remote data source (see Remote data source)
selected item details, 526–527
settings, 517
source setting, 515
ui-widget class, 516
button, 485
custom image, 484
enable and disable methods, 486–487
events, 488
HTML document, 479
label setting, 481
map object, 481
option argument with map object, 482
installation
progress bar
jQuery UI, progress bar (cont.)
determinate tasks, 493
indeterminate task, 493
slider
creation, 501
tabs configuration
ajaxOptions, 555
cache, 555
collapsible, 555
disabled, 555
disabling individual tabs, 560–562
event, 555
fx, 555
panelTemplate, 555
selected, 555
spinner, 555
tabTemplate, 555
theme
Sunny theme, 471
ThemeRoller page, 470
UI lightness, 471
jQuery UI datepicker widget
accordion methods, 611
basic datepicker settings
altField, 592
buttonImage, 592
buttonImageOnly, 592
buttonText, 592
disabled, 592
image instead of a button, 597
image rather than a button, 596–597
showOn, 592
showOn setting, 595
controlling appearance
appendText, 605
appendText setting, 610
bleed between months, 607, 608
button bar, 609
closeText, 605
currentText, 605
currentText and closeText settings, 608
duration, 605
gotoCurrent, 606
gotoCurrent setting, 609
HTML5 placeholder attribute, 610, 611
selectOtherMonths, 606
showAnim, 606
showButtonBar setting, 608
showButtonPanel, 606
showOptions, 606
showOtherMonths, 606
showWeek, 606
weekHeader, 606
getDate and setDate methods, 612–613
localizing date selection, 617–619
managing date selection
applying basic constraints, 598–599
changeMonth, 597
changeYear, 597
constrainInput, 598
constrainInput setting, 598
defaultDate setting, 601
delay window creation, 600
grid of months, 602
maxDate, 598
minDate, 598
minDate and maxDate settings, 599, 600
months and years, direct access, 604–605
multimonth datepicker, 603, 604
numberOfMonths, 598
numberOfMonths setting, 601–602
open-ended date selection range, 601
pop-up datepicker, 603
showCurrentAtPos, 598
showCurrentAtPos setting, 603
showOn setting, 598
stepMonths, 598
yearRange, 598
onChangeMonthYear event, 615–616
onClose event, 616
show and hide methods, 613–614
jQuery UI dialog widget
beforeClose event, 636
changing sizes and positions, 638–639
close event, 637
create event, 636
dialog box
autoOpen setting, 624
buttons setting, 625
closeOnEscape setting, 625
creation, 622
custom title and no resize drag handle, 626, 627
deferring,appearance, 623, 624
div element, 622
draggable and stack settings, 629, 630
draggable setting, 625
height setting, 625
hide setting, 625
maxHeight setting, 625
maxWidth setting, 625
minHeight setting, 625
minWidth setting, 625
modal setting, 625
resizeable setting, 625
show setting, 625
stack setting, 625
title setting, 625
width setting, 625
drag event, 636
dragStart event, 636
dragStop event, 636
focus event, 636
modal dialog
capture input,user, 634
input elements, 633
open and close methods, 631
open event, 636
preventing dialog,closing, 637–638
resize event, 636
resizeStart event, 636
resizeStop event, 637
jQuery UI tabs events
add, 576
button presses handling, 581
create, 576
disable, 576
enable, 576
form validation
alert box, 584
preventDefault method, 584
select and show events, 584
show method, 583
load, 576
preventDefault method, 581
remove, 576
select, 576
show, 576
ui object dispatched properties, 576
jQuery UI tabs methods
add and remove
automatically activating new tab, 567–568
empty div element, 570
html method, 569
input and pair of button elements, 566
input element, 567
newly added static tab, 569
panel, 569
panelTemplate setting, 569
programmatically added static tabs, 570
remove active tab button, 566
tabsElem.tabs(), 566
ui object, 568
val method, 567
tabs("abort"), 565
tabs("add"), 564
tabs("destroy"), 564
tabs("disable"), 564
jQuery UI tabs methods (cont.)
tabs("enable"), 564
tabs("length"), 565
tabs("load"), 565
tabs("option"), 564
tabs("remove"), 564
tabs("rotate"), 565
tabs("select"), 564
tabs("url"), 565
jQuery utility methods, 903, 918
arrays
HTMLElement arrays, 908
contains method, 918
data, 915
serializeArray method, 915, 916
trim method, 917
general-purpose queues, 904
css method, 906
delay method, 906
dequeue method, 906
queue items, manual process, 906–907
val method, 906
proxy function creation, 919
working with types, 913
jquery.mobile-1.0.css file, 731
jquery.mobile-1.0.js file, 731
JsFiddle, 9
JSON.stringify method, 425
Keyboard event shorthand methods, 246
legend element, 847
List widgets
filtering lists
custom filter function, 867–868
data-filter attribute, 863–865
formatting
data attributes, 857
formatting items
data attributes, 868
list dividers, 869
Live event binding
append methods, 234
automatically registering event handlers method, 234
bind method, 234
die method, 236
live method, 235
loadingMessage property, 783
Manually invoking event handlers
methods, 237
triggerHandler method, 240–241
triggering, 238
Metadata elements
script element, 20
style element, 21
Microsoft IIS 7.5, 331
mobileinit event, 769–770, 783
Mouse event shorthand methods, 244–245
myData.weather, 94
newContent property, 546
oldContent property, 546
Opera Emulator, 838
Opera Mobile Emulator, 756
orientationchange event, 748–749, 835
Outcome-indifferent callbacks, 953–956
pagehide event, 790
Pages and navigation,
browser display, 763
control script
activatePage property, 784–785
changePage method (see changePage method)
data-role attribute, 762
document
multiple jQuery Mobile pages, 766
navigate between pages, 766–767
events, 787
initialization, 787
external pages
href attribute, 771
script and link elements, 773
headers and footers addition, 763–764
degree of consistency, 766
meta element, 765
Opera Mobile, 765
viewport, 765
HTML document, 762
parents method, 142
parentsUntil Method, 143
parseJSON method, 462
performLongTasksync function, 948
Per-pixel accuracy, 754
placeholder attribute, 833
placeholder element, 722
pop effect, 769
preventDefault function, 35, 386
primary icon, 483
printMessages method, 76
printQueue, 270
processServerResponse function, 386, 462
products property, 462
progress-animation.gif, 497
Range slider, 505–506, 851–852
Real numbers, 73
Refactored example, 431–434, 699
example document, 699
form data submission browser, 454
form data submission click event, 453–454
form data submission CSS and jQuery statements, 451–452
form data submission disabled attribute, 453
form data submission HTML elements, 452
form data submission img element, 452
form data submission name attribute, 453
form data submission progress, 452
form data submission serialize method, 453
form data submission using Ajax, 448–454
change event, 446
form element, 445
when and then methods, 445–446
place Order button click, 720–723
product information sourcing, 439–442
server response
enhancement support document, 455–460
order summary, 455
shopping basket addition, 702–704
Refactored example, shopping basket addition (cont.)
change event, 706
rows updation, 708
table addition, 705
theme style
document header, 711
jQuery UI CSS framework style, 709, 710
ui-widget-content class, 709
ui-widget-header, 709
wide framework styles, 710
Remote data source
function as data source, 521–522
generated data, 518
minLength and delay settings, 520–521
term, 518
removeTableRow function, 707, 708, 713
replaceWith and replaceAll methods, 178–179
Resizable interaction
alsoResize setting, 693
aspectRatio setting, 693
autoHide setting, 693
div elements, 692
drag handle to change, 693
ghost setting, 693
handles setting, 693
maxHeight setting, 693
maxWidth setting, 693
minHeight setting, 694
minWidth setting, 694
resizable method, 692
settings
drag handles, 696
resizable element size, 695–696
resizing related elements, 694–695
resize method, 542
Rounded corner classes, 932–933
script element, 770
secondary icon, 483
Selectable interaction
cancel setting, 690
enabling multiple element selection, 689
events, 691
mouse selection, 689
settings, 690
showErrors method, 463
showLoadMsg setting, 783
singlepage.html file, 776
slice method, 128
slide effect, 768
Sortable interaction
adding button,sort order, 676
change and sort events, 687
connectToSortable setting, 679, 680
dropOnEmpty setting, 677
events, 686
items setting, 677
sortable class, 675
sortable method, 674
sorted element order, 675
sorting item,dragging, 675
toArray method, 675
ui object properties, 686
styles.css file, 44
swiperight event, 781
tbody element, 713
tmpl method, 462
UI effects and CSS framework, 921, 927
cue classes
interaction state classes, 934–935
rounded corner classes, 932–933
show and hide elements, 928–929
widget container classes, 930–931
ui-hidden-accessible class, 834
ui-hidden-class, 833
ui.item object, 526
ui-progressbar class, 498
ui-progressbar-value class, 497
ui-widget-header class, 712
User agent styles, 53
vclick event, 747
vertical-align property, 48
virtual events, 747
vmousedown event, 746
vmouseover event, 746
weather property, 94
Widget container classes, 930–931
jQuery UI accordion widgets (see jQuery UI, accordion widgets)
jQuery UI autocomplete widgets (see jQuery UI, autocomplete widgets)
jQuery UI button (see jQuery UI, button)
jQuery UI progress bar (see jQuery UI, progress bar)
jQuery UI slider (see jQuery UI, slider)
52.14.204.142