Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support W3 Validation #31

Open
kmturley opened this issue Dec 11, 2015 · 1 comment
Open

Support W3 Validation #31

kmturley opened this issue Dec 11, 2015 · 1 comment

Comments

@kmturley
Copy link

Great plugin! I found an issues using w3 validation when using the element syntax:

<js-tag></js-tag>

This also doesn't work if there was a JavaScript error on the page the input wouldn't show. A better method would be to do the following:

<label for="tags">Tags</label>
<input id="tags" type="text" placeholder="Enter tags (separated by commas)" class="js-tag" />

The update your directive to have restrict = 'c' and replace = true to replace the input with class="js-tag":

jsTag.directive('jsTag', ['$templateCache', function($templateCache) {
    return {
        restrict: 'C',
        scope: true,
        controller: 'JSTagMainCtrl',
        replace: true,
        templateUrl: function($element, $attrs) {
            var mode = $attrs.jsTagMode || "default";
            return 'jsTag/source/templates/' + mode + '/js-tag.html';
        }
    };
}]);

This validates as html5 compliant and provides a working input field if the library where to fail for some reason!

Additional features could be:

  • Grab the placeholder text from the input field, for your tags text
  • Apply an option to only load the directive on desktop computers vs mobiles
@eranhirs
Copy link
Owner

Thank you for your contribution.
Removing jsTag as a custom tag is not an option, but adding support for jsTag via attributes is welcome. I would like you to open a PR for this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants