jerel / ember-cli-loading-slider

A YouTube like loading indicator for EmberJS packaged as an Ember CLI add-on.
MIT License
116 stars 36 forks source link

Cannot read property 'width' of undefined $.().width() #14

Closed aalimovs closed 8 years ago

aalimovs commented 8 years ago

Tried the addon on a fresh ember project, getting an error:

Uncaught TypeError: Cannot read property 'width' of undefined @ loading-slider.js:37

Same error at line 105 if expanding=true.

Am I missing something?

jerel commented 8 years ago

I think this might happen when the loading slider component is set to expanding before the route's template is rendered. This should be investigated and fixed, there's an open pull request related to it. On Nov 25, 2015 8:42 AM, "Alexander Alimovs" notifications@github.com wrote:

Tried the addon on a fresh ember project, getting an error:

Uncaught TypeError: Cannot read property 'width' of undefined @ loading-slider.js:37

Same error at line 105 if expanding=true.

Am I missing something?

— Reply to this email directly or view it on GitHub https://github.com/jerel/ember-cli-loading-slider/issues/14.

aalimovs commented 8 years ago

I had a look at the source, it seems to error because it tries to get width before didInsertElement() has done its job.

Moving this.manage() from initialize() to didInsertElement() fixed this. I'll do a PR later.

I'm not sure if there were any Ember changes that caused this, but I don't get how it's working for anyone else?

juanesarango commented 8 years ago

@aalimovs came here to report this same issue. I'm getting this error while making acceptance testing. Made the changes you propose locally while your fix is accepted and it works smoothly. Thanks man.