In the previous step, you added a C1NavigationList control and navigation items to the settings.aspx page. In this step, you will add behaviors to the Clear History, Clear Cookies, and Clear Cache buttons that you added to the navigation list. When one of the buttons is clicked, a dialog box will appear asking users if they're sure they want to clear their history, cookies, or cache.
Complete the following steps:
1. In the settings.aspx page, click the Source tab to enter Source view.
2. Add the following JavaScript beneath the </ScriptManager> tag:
<script type="text/javascript">
// handler for clickable items
function ItemClicked(item) {
var id = item.get_commandName();
var text;
var buttontext;
switch (id) {
case "history":
$().c1iPhone().c1confirm(function() { alert("Clear History confirmed"); }, "Are you sure you want to clear history?", { cancel: "Cancel it", ok: "Clear History" });
break;
case "cookie":
$().c1iPhone().c1confirm(function() { alert("Clear Cookies confirmed"); }, "Are you sure you want to clear all cookies?", { ok: "Clear Cookies" });
break;
case "cache":
$().c1iPhone().c1confirm(function() { alert("Clear Cache confirmed"); }, "Are you sure you want to clear the cache?", { ok: "Clear Cache" });
break;
default:
return;
}
}
</script>
In the next step, you will run the project and explore the behaviors you added to the launch pad and navigation list items.