Menu Confirm di Phonegap

Setelah membahas cara membuat context menu di postingan sebelumnya, sekarang saya akan coba menjelaskan cara untuk membuat confirm menu. Contoh sederhana javascript query dari phonegap:

// process the confirmation dialog result
function onConfirm(buttonIndex) {
    alert('You selected button ' + buttonIndex);
}

// Show a custom confirmation dialog
//
function showConfirm() {
    navigator.notification.confirm(
       'Ingin Keluar?',
    onConfirm,              // callback to invoke with index of button pressed
    'Confirm Exit..',            // title
    'No,Yes'          // buttonLabels
    );
}


Dan ini adalah contoh full source codenya. Jadi apabila memilih button exit, maka aplikasi akan keluar. Lihat:

<html>
  <head>
    <title>Notification Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        // Empty
    }

    // process the confirmation dialog result
    function onConfirm(buttonIndex) {
        alert('You selected button ' + buttonIndex);
    }

    // Show a custom confirmation dialog
    //
    function showConfirm() {
    navigator.notification.confirm(
    'Ingin Keluar?',
    onConfirm,              // callback to invoke with index of button pressed
    'Confirm Exit..',            // title
    'No,Yes'          // buttonLabels
    )
    }
    function onConfirm(buttonIndex) {
        if(buttonIndex == 2){
        <!-- navigator.app.exitApp(); --> 
        device.exitApp(); 
    }
    }
    </script>
  </head>
  <body>
    <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p>
  </body>
</html>

Dan nanti hasilnya akan seperti ini:
a
Untuk info lebih lanjut, silahkan ke sini http://docs.phonegap.com/en/2.5.0/cordova_notification_notification.md.html#notification.confirm

Advertisements

38 comments

  1. Ahaa, its good conversation on the topic of
    this article at this place at this website, I have read all that, so now me also commenting at this place.

  2. Definitely believe that that you said. Your favourite reason appeared
    to be on the internet the simplest factor to be mindful of.

    I say to you, I definitely get irked while folks think about concerns that they just don’t realize about.

    You managed to hit the nail upon the top as smartly
    as outlined out the whole thing without having side-effects , people could take a signal.
    Will probably be back to get more. Thank you

  3. Simply want to say your article is as amazing. The
    clarity in your post is simply cool and i can assume you are an expert
    on this subject. Well with your permission let me to grab your feed
    to keep updated with forthcoming post. Thanks a million and
    please keep up the enjoyable work.

  4. I have been exploring for a bit for any high quality articles or blog posts in this kind of area .
    Exploring in Yahoo I at last stumbled upon this site.
    Studying this information So i am glad to convey that I have
    a very excellent uncanny feeling I found out just what I needed.
    I such a lot indubitably will make certain to do not disregard this website and provides it
    a glance on a relentless basis.

  5. Hi, I do believe this is a great web site.

    I stumbledupon it 😉 I may return yet again since I book marked
    it. Money and freedom is the greatest way to change, may
    you be rich and continue to help other people.

  6. Hello there, I discovered your website by means of Google
    whilst looking for a related subject, your site got here
    up, it looks great. I’ve bookmarked it in my google bookmarks.

    Hi there, just was alert to your blog through Google, and located
    that it is truly informative. I’m going to watch out for brussels.
    I will appreciate for those who continue this in future.
    A lot of folks will likely be benefited out of your writing.

    Cheers!

  7. I’m now not certain the place you are getting your info, but good
    topic. I must spend some time studying much more or understanding more.
    Thank you for wonderful info I used to be searching for this info for my mission.

  8. hey there and thank you for your info – I have
    definitely picked up anything new from right here.
    I did however expertise several technical issues
    using this site, as I experienced to reload the site a lot of times
    previous to I could get it to load correctly. I had been wondering if your
    web host is OK? Not that I am complaining, but slow loading instances times will sometimes
    affect your placement in google and could damage your high quality score if ads and marketing
    with Adwords. Anyway I am adding this RSS to
    my e-mail and could look out for much more of your respective fascinating content.
    Make sure you update this again very soon.

  9. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make
    your point. You definitely know what youre talking about, why waste your intelligence on just posting videos to your blog when you could
    be giving us something enlightening to read?

  10. Woah! I’m really digging the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s difficult to get that “perfect balance” between user friendliness and visual appearance.

    I must say that you’ve done a very good job with this.

    Also, the blog loads very quick for me on Internet explorer.
    Superb Blog!

  11. Hey there! This is my first visit to your blog! We are a
    collection of volunteers and starting a new project in a
    community in the same niche. Your blog provided us beneficial information to work
    on. You have done a marvellous job!

  12. First off I would like to say excellent blog!
    I had a quick question that I’d like to ask if you do not mind.
    I was curious to find out how you center yourself and clear
    your mind before writing. I have had a tough time clearing my mind in getting my
    thoughts out. I do enjoy writing however it just seems like the first 10 to 15 minutes are generally wasted just trying to figure out how to begin. Any recommendations or tips?
    Kudos!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s