facebook

How to get buttonLabels value from phoneui.confirm? CLOSED

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #338000 Reply

    Muhammad
    Member

    I made image button that content as bellow,

    phoneui.confirm("Are you sure delete all bookmarks?", delete_all_bookmark(), "Delete All Bookmark", "Yes, No")
    

    When answer is “Yes” and then do delete_all_bookmark().
    How to know that the answer is Yes or No?

    I check on phoneui.js as this, but I dont get it.

    phoneui.confirm = function(message, fnContinue, title, buttonLabels) {
        if (phoneui.cordovaAvailable()) {
            navigator.notification.confirm(message, fnContinue, title, buttonLabels);
        } else {
            var res = confirm(message);
            fnContinue(res);
        }
    }

    From http://docs.phonegap.com/en/1.4.1/phonegap_notification_notification.md.html#notification.confirm example,
    they can revoke using “button” variable to get value of buttonLabels.

    #338055

    Muhammad
    Member

    Do you have answer for this one?

    #338077

    Yann
    Member

    hi Muhammad
    Solution

    function delete_all_bookmark(button)
    {
    if (button=='1')
    {
    // call function for yes 
    }
    else
    {
    //  call function for no or do nothing
    }
    }
    
    

    hope this help you
    Yann

    #338078

    Muhammad
    Member

    Hi Yann, thank you.

    I did like yours and I got error like this

    undefined: Can't find variable: button
    Stack:
    undefined ReferenceError: Can't find variable: button

    Do you know how to define a button variable?

    #338079

    Yann
    Member

    hi
    an error? try this

    function confirmDeleteBookmark ()
      {
      
       navigator.notification.confirm(
            'Are you sure delete all bookmarks?',  // message
         delete_all_bookmark,              // callback to invoke with index of button pressed
           'Warning',            // title
           'Yes,No'          // buttonLabels
       );
    
    }
    
    function delete_all_bookmark(button)
    {    if (button=='1')
        {
        //delete bookmark
        }
    
    }

    Yann

    #338146

    Muhammad
    Member

    Thank you Yann,

    I still got error like this.

    undefined: Result of expression 'navigator.notification' [undefined] is not an object.
    Stack:
    undefined TypeError: Result of expression 'navigator.notification' [undefined] is not an object. 
    #338150

    Yann
    Member

    Hello
    did you try in test center or a desktop navigator ?
    This function run as well but only in builded version (ipa or apk file)
    Yann

    #338172

    Muhammad
    Member

    I got that error on test center.
    And I test also on iPhone, and get button value still as “undefined”.

    Do you know how to get button value in that function?

    #338173

    Yann
    Member

    Have you build a ios app ?
    this function do not run on test center and phone if is not compiled in nativ app

    #338177

    Muhammad
    Member

    Yann thank you. I got it. I compaile it on mac and work fine.

    Thank you so much.

    #338178

    Yann
    Member

    You’re welcome
    glad to help you
    Yann

Viewing 11 posts - 1 through 11 (of 11 total)
Reply To: How to get buttonLabels value from phoneui.confirm? CLOSED

You must be logged in to post in the forum log in