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

Brent Lintner commented on RIPPLE-47:
-------------------------------------

Looks good to me. +1

IMO, perhaps a bit hacky (especially the "=== '[object Array]" logic), but, 
given the actual Cordova code ref, I suppose I can't complain, heh.

If no one disagrees, I'll merge this in once it is in (or rebased onto) the 
`next` branch (see GitHub PR comments).

> 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.1#6144)

Reply via email to