Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Run callback twice for keydown, keyup, blur, focus with Angular 1.3+ #15

@tuanchauict

Description

@tuanchauict

I found these issues comes because you add directives : ngKeydown, ngKeyup, ... into <tagger/> by hand. The issues are: run callback functions twice for keydown, keyup, ... events

Those directives have been done by angular 1.3 (I only touch 1.3+, I'm not sure with former versions)

Solution: check version before adding (line 6)

if(angular.version.major < 1 || angular.version.major == 1 && angular.version.minor < 3){
    _ref = ["ngKeydown", "ngKeyup", "ngBlur", "ngFocus"];
    _fn = function (directiveName) {
        return angular.module("tagger").directive(directiveName, [
            "$parse", function ($parse) {
                return function (scope, element, attr) {
                    var eventName, fn;
                    fn = $parse(attr[directiveName]);
                    eventName = directiveName.substring(2).toLowerCase();
                    return element.bind(eventName, function (event) {
                        fn(scope, {
                            $event: event
                        });
                        if (!(scope.$$phase || scope.$parent.$$phase || scope.$root.$$phase)) {
                            return scope.$apply();
                        }
                    });
                };
            }
        ]);
    };
    for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        directiveName = _ref[_i];
        _fn(directiveName);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions