[ 
https://issues.apache.org/jira/browse/RIPPLE-47?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14076075#comment-14076075
 ] 

Hugo Freire edited comment on RIPPLE-47 at 7/28/14 10:50 AM:
-------------------------------------------------------------

Works well until 0.9.21 (Included). Next releases button returns value + 1. In 
the next example the "Option 1" returns 2, "Option 2" returns 3 and "Option 3" 
returns 4, it should be 1,2 and 3.

{code:html}
<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <script type="text/javascript" src="cordova.js"></script>
    <script>
      var app = {
          initialize: function() {
              this.bindEvents();
          },
          bindEvents: function() {
              document.addEventListener('deviceready', this.onDeviceReady, 
false);
          },
          onDeviceReady: function() {
              app.receivedEvent('deviceready');
          },
          receivedEvent: function(id) {
    navigator.notification.confirm(
      "Test",
      function(option){
        console.log(option);
      },
      'Choice',
      ['Option 1','Option 2', 'Option 3']
    );

          }
      };
      app.initialize();
    </script>
  </body>
</html>
{code}


was (Author: tlmak0):
Works well until 0.9.21 (Included). Next releases button returns value + 1. In 
the next example the "Option 1" returns 2, "Option 2" returns 3 and "Option 3" 
returns 4, it's should be 1,2 and 3.

{code:html}
<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <script type="text/javascript" src="cordova.js"></script>
    <script>
      var app = {
          initialize: function() {
              this.bindEvents();
          },
          bindEvents: function() {
              document.addEventListener('deviceready', this.onDeviceReady, 
false);
          },
          onDeviceReady: function() {
              app.receivedEvent('deviceready');
          },
          receivedEvent: function(id) {
    navigator.notification.confirm(
      "Test",
      function(option){
        console.log(option);
      },
      'Choice',
      ['Option 1','Option 2', 'Option 3']
    );

          }
      };
      app.initialize();
    </script>
  </body>
</html>
{code}

> navigator.notification.confirm can't get correct index of button pressed
> ------------------------------------------------------------------------
>
>                 Key: RIPPLE-47
>                 URL: https://issues.apache.org/jira/browse/RIPPLE-47
>             Project: Apache Ripple
>          Issue Type: Bug
>         Environment: Ripple: 0.9.19
> Platform: Apache Cordova 3.0.0
>            Reporter: lmnbeyond
>            Priority: Minor
>
> Steps to reproduce it:
> 1. Use 'ripple emulate' to start cordova mobile spec tests
> 2. Select 'Apache Cordova 3.0.0'
> 3. Run Notification->Confirm Dialog, which will invoke the following method:
> navigator.notification.confirm('You pressed confirm',
>             function(r) {
>                 console.log("You selected " + r);
>                 alert("You selected " + (buttons.split(","))[r-1]);
>             },
>             'Confirm Dialog',
>             'Yes,No,Maybe');
> Results:
> Console window outputs:
> TypeError: Object [object Array] has no method 'split'
>     at _processConfirm 
>     at Object.module.exports.confirmNotification 
> After I referred to the confirm method which is defined in 
> org.apache.cordova.dialogs/www/notification.js, I found that the buttonLabels 
> may already be splitted:
> if (platform.id == "android" || platform.id == "ios" || platform.id == 
> "windowsphone" || platform.id == "firefoxos") {
>             if (typeof _buttonLabels === 'string') {
>                 var buttonLabelString = _buttonLabels;
>                 _buttonLabels = _buttonLabels.split(","); // not crazy about 
> changing the var type here
>             }
>         } else {
>             if (Array.isArray(_buttonLabels)) {
>                 var buttonLabelArray = _buttonLabels;
>                 _buttonLabels = buttonLabelArray.toString();
>             }
>         }
> I added a quick workaround for it, then the confirm dialog can be showed up. 
> But I found another issue: the  returned index of button pressed is 0, 1, 2, 
> which is different from Cordova definition:
> confirmCallback: Callback to invoke with index of button pressed (1, 2, or 3) 
> or when the dialog is dismissed without a button press (0). (Function)



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to