Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$.fn.ngattr: $ is undefined

See original GitHub issue

Using the latest version 1.0.12 we get this (console) error when loading the plugin. We have jQuery loaded.

Notice that everything works ok Drag and drop is ok, nothing else fails, except that because of this error some other functions/plugins might fail like ng-touch for example. Notice that we are using jQuery 1.9.1 as we are forced to continue using it for some parts of this old, huge application, but it’s loaded after angularand it’s plugins (so we should be working with the associatd jqLite))

We “fixed” it by using the old version 1.0.11 and we found that i fact this is the piece of code which complains:

angular-dragdrop.js: 410

 $.fn.ngattr = function(name, value) {
    var element = this[0];

    return element.getAttribute(name) || element.getAttribute('data-' + name);

If the first two lines are replaced by the old version which used prototyping it works:

angular.element.prototype.ngattr = function(name, value) {
    var element = angular.element(this).get(0);

    return element.getAttribute(name) || element.getAttribute('data-' + name);

As a side question, shouldn’t we pass angular.element instead of window.jQuery during initialization?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

codef0rmercommented, Oct 12, 2015

I do not think that $.fn call would break anyway because jQuery is required. Have a demo?

codef0rmercommented, Nov 28, 2015

Closing it as it does not look like a bug. Please reopen if the problem persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AngularJS: Add conditional add ng-onclick? - Stack Overflow
I tried to use the AngularJS directive ng-attr ng-attr-ng-click="{{options.fn||undefined}}" but it raises an error when using {{ }} and ...
Read more >
ngJq causes warning in Firefox · Issue #12741 - GitHub
$.fn.ngattr: $ is undefined codef0rmer/angular-dragdrop#214. Closed. Sign up for free to subscribe to this conversation on GitHub.
Read more >
watch)&&(c="$SCOPE");return c}function na(b,a){return"undefined"===typeof ... original=f;Ea.fn[b]=e}function S(b){if(b instanceof S)return b ...
Read more >
angular-dragdrop.js | searchcode
... angular, undefined) { 7'use strict'; 8 9var jqyoui = angular.module('ngDragDrop', ... 39 data = {}; 40 41 dragModel = $draggable.ngattr('ng-model'); ...
Read more >
Drag and Drop in AngularJS - Multiple Lists Demo - Plunker
isArray(dragModelValue) && dragSettings.index !== undefined) ... function() { if ($(ui.draggable).ngattr('ng-model') && attrs.ngModel) { ngDragDropService.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found