Wildhoney / EmberDroplet

Ember.js HTML5 file uploading with drag & drop and image/file preview.
http://ember-droplet.herokuapp.com/
MIT License
197 stars 31 forks source link

How do I get a controller's attribute into the view? #87

Closed matthewbga closed 9 years ago

matthewbga commented 9 years ago

For my application the uploaded file needs to be associated with a parent record, and that id is in the URL, like a POST to http://something.com/user/123/user_images. When I set dropletUrl to something like: dropletUrl: function() { return '/api/users/' + this.model('user_id') + '/user_images'; }

However, at runtime, this function's text is seen as string value, not executed, giving the exception: http://something.com/mbox/users/184/function%20()%20%7B%20%20%20%20%20…s/'%20+%20this.model('user_id')%20+%20'/user_images';%20%20%20%20%7D

How do I get that URL through to the dropletUrl?

TIA!

Wildhoney commented 9 years ago

Ah... Please try again with v0.9.8 :+1: Let me know if it works.

matthewbga commented 9 years ago

Excellent! Now the function is evaluated properly. However, this.get() is not recognized. I think I now have a scoping error.

this appears to point to window in this context.

Wildhoney commented 9 years ago

Sorry, my mistake! Please try with v0.9.9.

matthewbga commented 9 years ago

What can I say? Nailed it!

Thank you, sir!

Wildhoney commented 9 years ago

You're welcome :+1: