[ 4 posts ]

ispyinternet

  • Joined: Thu Jul 08, 2010 5:28 am
  • Posts: 111
  • Offline
  • Profile

Changing the container of a View

Post Posted: Tue Apr 10, 2012 7:26 am
+0-
Looking at the source for Y.View

in the initializer there is the following comment:

// When the container node changes (or when it's set for the first
// time), we'll attach events to it, but not until then. This allows the
// container to be created lazily the first time it's accessed rather
// than always on init.
this.after('containerChange', this._afterContainerChange);

The wording 'changes' is what I am getting at.

However the ATTRS for container are:

container: {
getter : '_getContainer',
setter : Y.one,
writeOnce: true
}

Why is the container a writeOnce attribute? In my application I want to use a nested (subview). when the parent view changes, I want to update the container for the subview so I dont have to keep creating a new subview. But I cant! I guess there is some rational behind this which I would be interested in finding out, otherwise lets remove the writeOnce!

Thanks,

Richard.

Ryan Grove

YUI Developer

  • Username: rgrove
  • Joined: Tue Dec 09, 2008 9:55 pm
  • Posts: 275
  • Location: Portland, OR
  • Twitter: yaypie
  • GitHub: rgrove
  • Gists: rgrove
  • IRC: rgrove
  • YUI Developer
  • Offline
  • Profile

Re: Changing the container of a View

Post Posted: Tue Apr 10, 2012 8:42 am
+0-
I briefly had some code in View that allowed the container to change after init. This worked great, but it introduced some complexity for Y.App that we weren't sure was worthwhile, so I reverted the change and made container writeOnce again.

This is good feedback, though. It's clear that people would find it useful to be able to change the container after init, so we'll look into bringing that functionality back.

Akshar Prabhu Desai

YUI Contributor

  • Username: akshar.prabhudesai
  • Joined: Tue Apr 05, 2011 2:42 pm
  • Posts: 17
  • GitHub: akshar100
  • Gists: akshar100
  • Offline
  • Profile

Re: Changing the container of a View

Post Posted: Tue Apr 10, 2012 9:27 am
+0-
Well I had filed a Bug with the same thing and after some discussion it go closed. As I worked more with Y.View I realized that having it writeOnce is actually a good strategy.

Even though you can not set the container after init, you can almost certainly do this.get('container').setHTML(Subview.render().get('container')) as many times as you want.

ispyinternet

  • Joined: Thu Jul 08, 2010 5:28 am
  • Posts: 111
  • Offline
  • Profile

Re: Changing the container of a View

Post Posted: Tue Apr 10, 2012 9:42 am
+0-
Ok, I am not sure why you decided it is actually a good strategy - could you explain? Also Im not sure my scenario relates to this.get('container').setHTML(Subview.render().get('container')) ?

I have a re-usable bit of the display that is rendered as a mini view and its container is a div within a larger view. There a number of larger views that want to contain this mini view, and so if the main page view changes, then the original container is lost and If I cannot change the container for the mini view, I would need to destroy, create new and restore state onto the newly available container.
  [ 4 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum