Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "hozkar"

Ok thank you so much, now it is working as an angular directive.

This is how I do it, maybe this could help someone:

  1. Create a new folder inside libs as bootstrap-confirmation and copy bootstrap-confirmation.min.js
  2. In ScriptPaths class, add the following const:
public const string Bootstrap_Confirmation = "~/libs/bootstrap-confirmation/bootstrap-confirmation.min.js";
  1. In AppBundleConfig class, add the new Boostrap_Confirmation url:
bundles.Add(
                new ScriptBundle("~/Bundles/App/libs/js")
                    .Include(
                        ScriptPaths.Json2,
                        ScriptPaths.JQuery,
                        ScriptPaths.JQuery_Migrate,
                        ScriptPaths.Bootstrap,
                        ...
                        ScriptPaths.Bootstrap_Confirmation,
                        ...

now, you can create an angular directive as you want:

(function () {
    appModule.directive('bowConfirmation', [
        function () {
            return {
                restrict: 'A',
                scope: {
                    bowConfirmationOptions: '=',
                    bowConfirmationOK: '&',
                    bowConfirmationCancel: '&',
                },
                link: function ($scope, element, attrs) {
                    $(element).attr('data-toggle', 'confirmation');
                    $(element).data($scope.bowConfirmationOptions);

                    //OK click
                    $(element).on("confirmed.bs.confirmation", function () {
                        $scope.bowConfirmationOK();
                    });
                    //Cancel click
                    $(element).on("canceled.bs.confirmation", function () {
                        $scope.bowConfirmationCancel();
                    });
                }
            };
        }
    ]);
})();

finally you can use your confirmation directive:

<button class="btn btn-default" bow-confirmation bow-confirmation-OK="vm.yes()" bow-confirmation-options='{"title": "New Title", "singleton": true}'>Confirmation</button>

Thanks.

Showing 21 to 21 of 21 entries