Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

ui-jq jQuery Passthrough doesn't support ng-model (for sliders etc) #233

Closed
jamie-pate opened this issue May 2, 2014 · 1 comment
Closed

Comments

@jamie-pate
Copy link

There's no way to use jqueryui's widgets that should/could be bound to ng-model (slider, progressbar, autocomplete?, spinner) ng-model should be set up to update the value of the plugin for these types.

i'll just leave this here: (this additional directive works for me)


function uiJq($timeout, $log) {
    return {
        require: '?ngModel',
        link: function(scope, elm, attrs, ngModel) {
            var block = false;
            if (ngModel) {
                ngModel.$render = function() {
                    block = true;
                    try {
                        plugin('value', ngModel.$viewValue);
                    } finally {
                        block = false;
                    }
                };
            }
            //specific events for slider, could add more.
            elm.on('slidechange slide', function(evt, ui) {
                if (!block) {
                    scope.$apply(function() {
                        ngModel.$setViewValue(plugin('value'));
                    });
                }
            });

            function plugin() {
                if (elm.is(':ui-' + attrs.uiJq)) {
                    return elm[attrs.uiJq].apply(elm, arguments);
                }
            }
        }
    }
}
@PowerKiKi
Copy link
Contributor

UI.Utils modules was split in individuals repositories. If still valid, please consider re-submitting the issue on its dedicated issue tracker.

See the README for details.

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

No branches or pull requests

2 participants