Search code examples
angularjs-directivekendo-tooltip

ISSUE: Kendo tooltip with custom angularjs directive and kendoConfirm


My current situation: kendo tooltip works fine alone. my new custom angularjs directive with kendoConfirm works fine alone.

but once i try to use them both together on an element, then only the kendo tooltip stops working.

   <button type="button" title="Disable Item" k-confirm-disable k-confirm-disable-title="'Confirm Disable'" k-confirm-disable-msg="'Are you sure you want to disable this item?'" ng-click="disable(dataItem.id)"  class="btn btn-danger" kendo-tooltip k-content="'Disable Item'" k-options="kendoTooltipOptions">

 $scope.kendoTooltipOptions = {
showAfter: 600,     //time for tooltip appear
position : 'top',
width    : 100
}

kendo tooltip only works when I remove the custom angular directive from the element.

function kConfirmDisable($compile){
return {
    restrict: 'A',
    scope: {
        kConfirmDisableTitle:   '@',
        kConfirmDisableMsg: '@'
    },
    link: function(scope, element, attrs){                      

        var clickHandlers = $._data(element[0]).events.click;

        clickHandlers.reverse(); //reverse the click event handlers list

        var onClick = function(evt) {                        
            evt.preventDefault();
            evt.stopImmediatePropagation();
            if(!scope.kConfirmDisableTitle) {
                scope.kConfirmDisableTitle = "Confirm";
            }

            if(!scope.kConfirmDisableMsg) {
                scope.kConfirmDisableMsg = "Are you sure?";
            }

            angular.element("<div></div>").kendoConfirm({
                title: scope.kConfirmDisableTitle.replace(/['"]+/g, ''),
                content: scope.kConfirmDisableMsg.replace(/['"]+/g, ''),
                buttonLayout: "normal",
                visible: false,
                actions: [
                     {
                        text: "No",
                        Primary: false,
                        action: function(){

                            evt.preventDefault();
                            evt.stopImmediatePropagation();                                
                        }
                    },
                    {
                        text: "Yes", 
                        Primary: true,
                        action: function(){                               

                            element.unbind(this);
                            setTimeout(function() {
                                element.unbind("click", onClick);
                                element.click();
                                evt.preventDefault();
                                evt.stopImmediatePropagation();
                                element.on("click", onClick);
                            },0);
                        }
                    },

                ],
                animation: {
                    open:{
                        effects: "zoom:in",
                        duration: 250
                    },
                    close:{
                        effects: "fade:out",
                        duration: 250
                    }
                },
                open: function(e) {
                   $("html, body").css("overflow", "hidden");
                },
                close: function() {
                    $("html, body").css("overflow", "visible");
                }
            }).data("kendoConfirm").open().result;
        };
        element.on("click", onClick);

        clickHandlers.reverse();
    }
}
}

Solution

  • my solution is I removed the "k-" from the "k-confirm-disable" directive and it worked. i think its because kendo has "k-" reserved.