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 87 | Next

Richard Wagner

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


Handling Link Clicks
Because most of the user interaction with an iPhone/iPod touch application is tapping the interface to
navigate the application, iUI ??™ s event listener for link clicks is, in many ways, the ??? mission control center ???
for iui.jss. Check out the code:
addEventListener(???click???, function(event)
{
var link = findParent(event.target, ???a???);
if (link)
{
function unselect() { link.removeAttribute(???selected???); }
if (link.href & & link.hash & & link.hash != ???#???)
{
link.setAttribute(???selected???, ???true???);
iui.showPage($(link.hash.substr(1)));
setTimeout(unselect, 500);
}
(continued)
Chapter 3: Implementing the Interface
72
else if (link == $(???backButton???))
history.back();
else if (link.getAttribute(???type???) == ???submit???)
submitForm(findParent(link, ???form???));
else if (link.getAttribute(???type???) == ???cancel???)
cancelDialog(findParent(link, ???form???));
else if (link.target == ???_replace???)
{
link.setAttribute(???selected???, ???progress???);
iui.showPageByHref(link.href, null, null, link, unselect);
}
else if (!link.target)
{
link.setAttribute(???selected???, ???progress???);
iui.showPageByHref(link.href, null, null, null, unselect);
}
else
return;
event.


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