SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 88 | Next

Richard Wagner

"Professional iPhone and iPod touch Programming: Building Applications for Mobile Safari"

preventDefault();
}
}, true);
This routine evaluates the type of link that it is:
If it is an internal URL, then the page is passed to iui.showPage() .
If the backButton is tapped, then history.back() is triggered.
Dialog forms typically contain a Submit and Cancel button. If a Submit button is tapped,
then submitForm() is called. If a Cancel button is tapped, then cancelDialog() is called.
(The submitForm() and cancelDialog() functions are discussed later in the chapter.)
External URLs that have target=???_replace??? or that do not have target defined are AJAX
links. Both of these call the iui.showPageByHref() method.
If it is none of these, then it is an external link with a target=???_self??? attribute defined and the
default iUI behavior is suspended and the link is treated as normal.
Handling AJAX Links
When an AJAX link is tapped by the user, the click event listener (shown previously) calls the
iui.showPageByHref() method:
showPageByHref: function(href, args, method, replace, cb)
{
var req = new XMLHttpRequest();
req.onerror = function()
{
if (cb)
cb(false);
};
req.onreadystatechange = function()
{
if (req.readyState == 4)
??‘
??‘
??‘
??‘
??‘
(continued)
Chapter 3: Implementing the Interface
73
{
if (replace)
replaceElementWithSource(replace, req.


Pages:
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100