eviltrout / ember-cloaking

Support for not rendering offscreen views in an Ember app for performance
MIT License
294 stars 29 forks source link

using `context` over `content` for cloaked views #5

Closed H1D closed 10 years ago

H1D commented 10 years ago

Thing is that context automatically goes as template context while content not. Actually I see the only way to use object from content in templates: bind context to content: contextBinding: 'content'.

BTW really interesting question is why Ember.CollectionView puts items to content for it's childViews

H1D commented 10 years ago

Here is example with original ember-cloaking http://jsbin.com/ACikukuCA/11/edit And forked version http://jsbin.com/ACikukuCA/14/edit

the only difference is that original have this line: contextBinding: 'content'.

eviltrout commented 10 years ago

It seems to work in your jsbin, but when I try this patch on Discourse it refuses to work. Here's one of the errors, which is weird:

screen shot 2014-01-27 at 3 40 13 pm

H1D commented 10 years ago

@eviltrout maybe because Discourse designed so that it's expects content? But Ember itself using context: http://emberjs.jsbin.com/AtEXixOb/2/edit

I think it's better for Ember plugin to follow Ember's own style

dogawaf commented 10 years ago

Hi,

For me, ember-cloaking does not work without this patch.

H1D commented 10 years ago

According to Ember documentation:

By default, Ember.View will look for a function in the template property and invoke it with the value of context. The value of context will be the view's controller unless you override it.

eviltrout commented 10 years ago

Gonna merge this in since it's the right thing to do, and fix Discourse before upgrading in there.

eviltrout commented 10 years ago

P.S. Thanks!