Closed beclamide closed 9 years ago
Turn on the debugger. The error message alone is very vague, I'm afraid. :)
Thank for the reply, I've been banging my head against a wall with this for hours.
Here's the error I get in Chrome. I'm going through trying to work out where and why the errors are occuring.
TypeError: undefined is not a function
at preLink (http://localhost:9000/bower_components/angular-masonry/angular-masonry.js:117:19)
at invokeLinkFn (http://localhost:9000/bower_components/angular/angular.js:8141:9)
at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7632:11)
at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7009:13)
at publicLinkFn (http://localhost:9000/bower_components/angular/angular.js:6888:30)
at chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:1532:22
at http://localhost:9000/bower_components/angular-ui-router/release/angular-ui-router.js:3905:9
at invokeLinkFn (http://localhost:9000/bower_components/angular/angular.js:8141:9)
at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7653:11)
at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7009:13) <div masonry="" class="ng-scope">```
I'm getting the same error. In fact, the angular-masonry demo (http://www.directiv.es/angular-masonry) is giving the same error and is no longer working. I believe the demo here used to work.
Not sure what's going on.
I believe it's something to do with the latest version of Masonry. I've got a deadline on a project so I've had to put this to one side for now, but I'll definitely investigate further when I can.
I had the exact same error message down to the line number involved and found that jquery-bridget was not being downloaded into the vendor folder. Had to manually add jquery-bridget to my bower.json and it works fine now with the latest version of every vendor module involved.
Complete javascript include list (sorry theres some stuff not strictly related to this):
'vendor/jquery/dist/jquery.js',
'vendor/jquery-bridget/jquery.bridget.js',
'vendor/get-style-property/get-style-property.js',
'vendor/get-size/get-size.js',
'vendor/eventEmitter/EventEmitter.js',
'vendor/eventie/eventie.js',
'vendor/doc-ready/doc-ready.js',
'vendor/matches-selector/matches-selector.js',
'vendor/outlayer/item.js',
'vendor/outlayer/outlayer.js',
'vendor/masonry/masonry.js',
'vendor/imagesloaded/imagesloaded.js',
'vendor/angular/angular.js',
'vendor/angular-sanitize/angular-sanitize.min.js',
'vendor/angular-google-chart/ng-google-chart.js',
'vendor/angular-bootstrap/ui-bootstrap-tpls.min.js',
'vendor/placeholders/angular-placeholders-0.0.1-SNAPSHOT.min.js',
'vendor/angular-ui-router/release/angular-ui-router.js',
'vendor/angular-cookies/angular-cookies.js',
'vendor/angular-camera/dist/angular-camera.js',
'vendor/flow.js/dist/flow.min.js',
'vendor/momentjs/min/moment.min.js',
'vendor/ng-flow/dist/ng-flow.min.js',
'vendor/angular-masonry/angular-masonry.js'
Complete bower.json:
{ "name": "xxxxxxx", "version": "0.3.2", "devDependencies": { "angular": "latest", "angular-mocks": "latest", "bootstrap": "latest", "angular-bootstrap": "latest", "angular-ui-router": "latest", "font-awesome": "latest", "animate-css": "latest", "jquery": "latest", "jquery.ui": "latest", "angular-sanitize": "latest", "angular-google-chart": "latest", "angular-cookies": "latest", "ng-flow": "latest", "angular-camera": "latest", "momentjs": "latest", "masonry": "latest", "angular-masonry": "latest", "jquery-bridget": "latest" }, "dependencies": {}, "resolutions": { "angular": "1.3.7", "masonry": "3.1.5" } }
Hope that helps.
manually adding jquery-bridget worked for me
after manually adding bridget I still got this error, the work around for me was adding load-images="false"
as an attribute to the <div masonry
Neither adding jquery-bridget nor adding load-images="false" to <div masonry worked for me.
@mikefab I found out the error may have several causes, this library depends on a few other js libraries, but not all the time, so to see which one you are missing, go ahead and use the non min version of the plugin, then on the stack trace you should be able to see which function call is the one being undefined, that should then help track down which library you are missing
@dddaaammmooo thank you, adding the jquery-bridget worked for me.
Hi @passy
I am also getting the same error when i try to run the example in my local. From the error message, looks like it is not recognising the masonry elements - line no 62 and 100.
script.js var app = angular.module("masonryExample", ['wu.masonry']); .... index.html - scripts added src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js" src="script.js" src="angular-masonry.js"
*Error
TypeError: undefined is not a function
at preLink (file:///Users/selva/learn/angularjs/angularjs-examples/instant-search/angular-masonry.js:117:19)
at i (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js:43:396)
at e (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js:39:307)
at i (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js:43:454)
at e (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js:39:307)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js:38:372
at https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js:16:160
at Object.e.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js:88:347)
at Object.e.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js:88:454)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js:16:116
@selvait90 Could you check which lines this refers to in your installation? There's most certainly a missing dependency somewhere. :)
thanks a lot @passy I was able to resolve the error by adding dependencies in following order.
src="jquery-1.11.2.min.js"
src="masonry.pkgd.min.js"
src="imagesloaded.pkgd.min.js"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"
src="angular-masonry.js"
src="myApp.js"
But I am developing the application in pure javascript without jQuery, So Is there way to get rid of the jQuery dependency in masonry plugin?
I have the same question as @selvait90 . Can I use masonry without jquery? Because the documentation said that I can, but actually I got next errors:
TypeError: undefined is not a function
at link.pre (http://localhost:8080/app/js/scripts.js:11952:29)
at invokeLinkFn (http://localhost:8080/app/js/scripts.js:3492:21)
at nodeLinkFn (http://localhost:8080/app/js/scripts.js:3270:21)
at compositeLinkFn (http://localhost:8080/app/js/scripts.js:3108:21)
at compositeLinkFn (http://localhost:8080/app/js/scripts.js:3108:119)
at compositeLinkFn (http://localhost:8080/app/js/scripts.js:3108:119)
at $get.node (http://localhost:8080/app/js/scripts.js:3089:40)
at link (http://localhost:8080/app/js/scripts.js:8056:17)
at invokeLinkFn (http://localhost:8080/app/js/scripts.js:3492:21)
at nodeLinkFn (http://localhost:8080/app/js/scripts.js:3274:87) <div masonry="{ 'isFitWidth': true }" class="masonry">
TypeError: undefined is not a function
at appendBrick (http://localhost:8080/app/js/scripts.js:11931:119)
at link.pre (http://localhost:8080/app/js/scripts.js:11974:26)
at invokeLinkFn (http://localhost:8080/app/js/scripts.js:3492:21)
at nodeLinkFn (http://localhost:8080/app/js/scripts.js:3270:21)
at compositeLinkFn (http://localhost:8080/app/js/scripts.js:3108:21)
at $get.node (http://localhost:8080/app/js/scripts.js:3089:40)
at $get.boundTranscludeFn (http://localhost:8080/app/js/scripts.js:3121:59)
at controllersBoundTransclude (http://localhost:8080/app/js/scripts.js:3212:25)
at http://localhost:8080/app/js/scripts.js:7332:32
at Object.$watchCollectionAction [as fn] (http://localhost:8080/app/js/scripts.js:4718:92) <div class="masonry-brick md-whiteframe-z1 ng-scope" ng-repeat="pictureThumbnail in pictureThumbnails">
Latest masonry already goes without jQuery. I totally think angular-masonry should remove jQuery depedency too.
I think @passy already had a feature quest for removing jqeury dependency.
I'm still getting this issue. Dependencies set up in the right order (referring to previous posts). I am using browserify to bundle all JS, could that be causing an issue?
var $ = require('jquery'); require('angular'); require('angular-ui-router'); require('jquery-ui'); require('angular-sanitize'); require('angular-module-animate'); require('jquery-bridget'); require('masonry-layout'); require('imagesloaded'); require('../../bower_components/angular-masonry/angular-masonry');
Error I'm getting:
TypeError: undefined is not a function at preLink (http://localhost/test/public/build/js/bundle.js:118:19) at nodeLinkFn (http://localhost/test/public/build/js/bundle.js:12832:13) at compositeLinkFn (http://localhost/test/public/build/js/bundle.js:12246:13) at publicLinkFn (http://localhost/test/public/build/js/bundle.js:12142:30) at compile (http://localhost/test/public/build/js/bundle.js:5819:9) at nodeLinkFn (http://localhost/test/public/build/js/bundle.js:12852:13) at compositeLinkFn (http://localhost/test/public/build/js/bundle.js:12246:13) at publicLinkFn (http://localhost/test/public/build/js/bundle.js:12142:30) at updateView (http://localhost/test/public/build/js/bundle.js:5757:23) at http://localhost/test/public/build/js/bundle.js:5719:11
Fixed by including imagesloaded!
+1 for missing jquery-bridget
adding jquery-bridget worked for me as well
I think the problem for the people without the fix (adding jquery-bridget) is simply requiring jquery-bridget before requiring the first masonry dependency. I had the problem that I was working with bower and the dependencies were required before jquery-bridget. Moving jquery-bridget to the top fixed the problem.
any latest solution for this problem? I still facing the same problem, after added with jquery-bridget.js and also include the (load-images="false" to <div). Still having with "undefined" problem. Much appreciated if anyone can help. Thanks.
I think it might be helpful for some (like me :P) to be a bit more explicit about including the dependencies in the html/js build.
I do now see that step 3 under #Usage in the readme is "Include dependencies in your HTML." but I came to the plugin through the homepage first, which doesn't make any mention of it. So I was confused for a bit there.
What worked for me was including masonry and imagesloaded in my build system (after jQuery, before angular, not sure if it matters).
I didn't (at least as of yet) need to install jquery-bridget...
Hi. I have fixed this problem.
First, I manually downloaded [jquery-bridget] [imagesloaded] from bower. Second, I checked depedencies. Finally,
script src="bower_components/jquery/dist/jquery.js" script src="bower_components/jquery-bridget/jquery.bridget.js" script src="bower_components/masonry/dist/masonry.pkgd.js" script src="bower_components/imagesloaded/imagesloaded.pkgd.js" script src="bower_components/angular/angular.js" script src="bower_components/angular-route/angular-route.js" script src="bower_components/angular-resource/angular-resource.js" script src="bower_components/angular-cookies/angular-cookies.js" script src="bower_components/angular-masonry/angular-masonry.js"
I loaded js files like this and error disappeared.
Moving jquery-bridget up to the top of the bower dependencies list sorted it for me.
@clov3rly's answer worked for me. Including mansory before angular.
it's a broserify problem, it load dependency ordered as bower.json file, add first jquery and jquery-bridge and work.
Hi all, I sorted it by placing my script as below order:
script src="lib/jquery.js" script src="lib/jquery.bridget.js" script src="lib/angular.js" script src="lib/angular-route.js" script src="lib/firebase.js" script src="lib/angularfire.min.js" script src="lib/bootstrap.js" script src="lib/ui-bootstrap-tpls-0.12.1.js" script src="lib/masonry.pkgd.min.js" script src="lib/imagesloaded.pkgd.js" script src="lib/angular-masonry.js"
But, I have a problem now, sometimes the pictures is loaded as 1 single column(vertically), sometimes it was fine. Any idea? Thanks.
@kentbong I think we need some more insights into this, because we need to reproduce the error somehow.
here is a fiddle that trhows this error: @passy http://jsfiddle.net/c8dn82vp/
I also have this problem, it works when I add jquery-bridget to bower.js and make it before angular-mansory.
"jquery-bridget": "~1.1.0",
"angular-masonry": "~0.8.1",
Hi I have the same problem that @kentbong reported.
Sorry, but this is impossible to look at for individual cases. It's always the loading order and there are plenty examples that have the correct one and I'd recommend to not do this manually at all and rely on some module loader or tools like wiredep to deal with it.
Hey. Why is this issue closed? I tried to include manually all the dependencies (imageloaded, jquery, jquery-bridget...) and try all different orders but still get the same error. By the way, the demo URL does not work anymore so I really think there is a bug http://www.directiv.es/angular-masonry Could you please re open?
Solved by uninstalling angular-masonry, then installing jquery-bridget before reinstalling angular-masonry. This should be fixed in angular-masonry's bower dependencies...
+1 to @OverlappingElvis' fix, thanks!!
+1 to @OverlappingElvis
These dependencies should be listed on the home page.
All 10 of them ... such a shame, it was looking promising for our project, but adding 10 additional libraries just to make Masonry work with Angular just isn't going to happen.
Hey Just got the same issue.
Reordering dependancies in bower.json solved my problem:
"dependencies": {
"jquery": "~2.1.0",
"jquery-bridget": "~1.1.0",
"angular": "~1.3.0",
"masonry": "~3.2.0",
"imagesloaded": "~3.1.0"
}
Totally agree with @stuartm. I use wiredep as @passy mentioned but actually the dependancies are removed then reinjected each time I build so the order of dependencies in bower.js matters. And it shouldn't =)
@fourmisz +1
Issue is in this library. Yes, masonry currently has "no jQuery" support and I'm not using jQuery in my AnguarJS application atm. BUT Issue is in this line in angular-masonry.js. That may be issue in all other element.masonry() referencies as well. Like current masonry readme says masonry can be initialized like this without jQuery
// vanilla JS
var grid = document.querySelector('.grid');
var msnry = new Masonry( grid, {
// options...
itemSelector: '.grid-item',
columnWidth: 200
});
I have the same issue with the current demo now. I agree with @RopoMen. Is there anyway to solve for current version?
I was including all of the correct dependencies in the correct order as mentioned above in the documentation. However, I was referencing them after my main vendor.js that gulp creates – so it was making one big js file with everything in an undefined order.
I moved the list of dependencies above this block and it works. If you're using gulp maybe check this.
<!-- build:js(src) scripts/vendor.js -->
<!-- bower:js -->
<!-- run 'gulp inject' to automatically populate bower script dependencies -->
<!-- endbower -->
<!-- endbuild -->
@iDuuck your solution worked for me! Moving jquery-bridget to the top fixed the problem ;)
+1 adding jquery-bridget fixed the issue
I've just installed the Bower package and I'm getting a TypeError: undefined is not a function error in Chrome when the page loads.
I found that other people have had the error when scripts aren't loaded in the correct order, but I think I'm doing it right.
I've made sure jQuery is 2.1.1 too. Does anyone have any ideas?