Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Forced autorender composed views #809

Open
Grygir opened this issue Jun 12, 2014 · 1 comment
Open

Forced autorender composed views #809

Grygir opened this issue Jun 12, 2014 · 1 comment

Comments

@Grygir
Copy link

Grygir commented Jun 12, 2014

Why composed views are always auto-rendered, disregarding what autoRender flag is?

            if disabledAutoRender and typeof @item.render is 'function'
              @item.render()

It's inconvenient in case you want a view to be rendered only after certain event. The only option I've found is to override render method and check there if it's ready to be rendered. This workaround is close to a hack. It would be better to support a proper option autoRender.

Thanks.

@ghost
Copy link

ghost commented Jun 20, 2014

@Grygir by default Chaplin.View is set to autoRender: false. Some implementations override this functionality, allowing views to auto-render by default. Chaplin.CollectionView will render automatically when the backing model is hydrated, though this behavior could also be overridden by extending that class.

If you're finding views created with Chaplin.Composition are somehow rendered automatically, but do not automatically render when compositions are not used, try the composer's long form syntax when creating your composition:

$pageLoaded = new $.Deferred
...
$pageLoaded.resolve()
...
@compose 'sidebar',
  compose: =>
    collection = @compose('search')
    $.when($pageLoaded).then ->
      new SearchView {collection, region: 'sidebar'}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant