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

Remove unnecessary dependence on jQuery #56

Closed
ghost opened this issue Aug 7, 2013 · 4 comments
Closed

Remove unnecessary dependence on jQuery #56

ghost opened this issue Aug 7, 2013 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 7, 2013

I changed two lines in ng-table and now I can use it without jQuery.

I don't have time to make a pull-request yet, but I hope I will find time in the next days.

Basically I change a line el = $(item) to 'el = anguler.element(item)' and replaced element.filter("thead") .remove(); with element.find("thead") .remove();

In the examples jQuery is often used for a loading layer. This is not the angular way of live IMHO:

        .directive('loadingContainer', function () {
            return {
                restrict: 'A',
                scope: false,
                link: function(scope, element, attrs) {
                    var loadingLayer = $('<div class="loading"></div>').appendTo(element);
                    $(element).addClass('loading-container');
                    scope.$watch(attrs.loadingContainer, function(value) {
                        loadingLayer.toggle(value);
                    });
                }
            };
        })

This could be replaced with something like:

        .directive('loadingContainer', function () {
            return {
                restrict: 'A',
                scope: false,
                template: '<div class="loading-container><div class="loading" ng-show="isLoading"></div></div>'
                link: function(scope, element, attrs) {
                    scope.$watch(attrs.loadingContainer, function(value) {
                        scope.isLoading = attrs.loadingContainer === "loading"
                    });
                }
            };
        })

or even simplier. I don't want to include the big old jquery for that if angular can handle that itself :)

Are there any reason why jQuery is really needed?

Nice module anyway!
Greets,
maklemenz

@esvit
Copy link
Owner

esvit commented Aug 8, 2013

It will work without jQuery only when will be fixed bug angular/angular.js#1459
jQuery needs only for correct template compilation $('<tr>...</tr>')

@esvit esvit closed this as completed Aug 8, 2013
@ghost
Copy link
Author

ghost commented Sep 2, 2013

Related pull request: angular/angular.js#3647

@WhiteMarlin
Copy link

I proceeded as did maklemenz in the original post; but in addition to the two lines he mentioned, I also changed the line

headerTemplate = $compile("<thead ng-include=\"templates.header\"></thead>")(scope);

to

headerTemplate = [$compile("<table><thead ng-include=\"templates.header\"></thead></table>")(scope)[0].tHead];

to work around the $compile issue.

@uxmaster
Copy link

I think it's fixed in 1.2.13, see angular/angular.js@31c450b

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

3 participants