Materialize: Cannot set property 'Picker' of undefined

Created on 10 May 2016  路  6Comments  路  Source: Dogfalo/materialize

I tried to merge jquery.js and materialize.js using gulp but the browser complained
'Cannot set property 'Picker' of undefined'

I also tried to load jquery via cdn and I had the same problem.

what is the right way to embed jquery and materialize?

bug thirdparty

Most helpful comment

I had this problem too and it was because of "use strict"; code that is attached at the start of the concatenated files. I don't know why but removing that code the error disappears.

All 6 comments

@brlebtag Did you find out what was wrong? I'm having the same problem here

Yes. I was also using babel to convert es5 to es2015. Babel converts "this" to "undefined". I believe your problem is the same. You need to remove materialize from babel pipeline and only merge the files.

@brlebtag Could you please describe your solution. I running into this issue while using aot compilation.

my problem was caused by Babel. it convertes "this" to "undefined". you need to remove "Materialize/js/date_picker/picker.js" and "Materialize/js/date_picker/picker.date.js" from your build pipeline. In my case I created 2 pipelines: pure es5 and es6 to es5. the former is js es5 only (no convertion). I added the files I mentioned above to it. The latter converts es6 to es5, after the convertion I merged both results and generated the final .js file. I hope it helps you now.

I had to hack the code to explicitly set Picker on window, ie - window.Picker = factory( ..., and I'm just concating the generated dist files - no modules, loaders, transpilers, etc, so there's clearly something wrong here.

I had this problem too and it was because of "use strict"; code that is attached at the start of the concatenated files. I don't know why but removing that code the error disappears.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ruslandzhumaev picture ruslandzhumaev  路  3Comments

hartwork picture hartwork  路  3Comments

acierpinski picture acierpinski  路  3Comments

samybob1 picture samybob1  路  3Comments

bradley-varol picture bradley-varol  路  3Comments