Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IIF in JavaScript
Message
 
 
À
05/08/2014 05:02:49
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01605133
Message ID:
01605179
Vues:
41
I am having troubles with disable-action.

I want to set it to the variable.

Here is what I get when I inspect the element. The button is not disabled and I want it disabled:
<a class="btn btn-default ng-isolate-scope ng-binding" ng-click="click()" ok-action="clearEMessage()" 
disable-action="disableClearMessage" 
link-text="Clear E-Messages" cancel-label="No" ok-label="Yes" 
confirm-message="'Are you sure you want to clear all e-messages?'" 
confirm-title="Confirm Clear" ng-disabled="true">Clear E-Messages</a>
I changed the directive this way:
app.directive('confirmButton', [function() {
        return {
            restrict: 'AE',
            transclude: true,
            replace: true,
            scope: {
                linkText: '@',
                okLabel: '@',
                cancelLabel: '@?',
                confirmTitle: '@',
                confirmMessage: '=',
                onOpen: '&',
                okAction: '&',
                disableAction: '='
            },
            controller: ['$scope', '$modal', function($scope, $modal) {
                $scope.okClass = 'btn-danger';
                $scope.message = $scope.confirmMessage;
                $scope.title = $scope.confirmTitle;
                //      $scope.okLabel = $scope.okLabel;
         //       console.log('Before: ' + $scope.cancelLabel);
                $scope.cancelLabel = $scope.cancelLabel || 'Cancel';
         //       console.log('After: ' + $scope.cancelLabel);

                $scope.click = function () {
                  
                    if ($scope.onOpen) {
                        $scope.onOpen();
                    }
                    var modal = $modal.open({
                        scope: $scope,
                        templateUrl: '/app/templates/modal.html'
                    });

                    modal.result.then(function (result) {
                        $scope.okAction();
                    });
                };
            }],
            template: '<a ng-click="click()" ng-disabled=" {{ disableAction }} " >{{ linkText }}</a>'
        };
    }]);
So, now it evaluates the disableAction. The disable-action I set to the name of the variable disableClearMessage and this variable is true when I open that form. So, the button should be disabled (and ng-disabled = 'true') as you see.

However, the button is not disabled and I can click on it just fine and the click event works. It may be a minor problem since the only reason I want to disable the button if there is nothing to clear (the message is empty anyway).
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform