[ 5 posts ]

Daniel Ji

  • Username: humblepie
  • Joined: Tue Feb 28, 2012 10:30 am
  • Posts: 147
  • GitHub: humblepie
  • Gists: humblepie
  • Offline
  • Profile

YUI View - container attribute removes id

Post Posted: Thu Mar 29, 2012 6:34 pm
+0-
Hello,

I was testing out the YUI View component
Code:
Y.PieView = Y.Base.create('pieView', Y.View, [], {
    ...
}, {
    // Specify attributes and static properties for your View here.
    ATTRS: {
        // Override the default container attribute.
        container: {
            valueFn: function () {
                return Y.Node.create('<div id="pie"/>');
            }
        }
    }
});
and I ran into an issue. It seems that if I create a new div node in the container ATTR with an id, then when I try to get the container instance in the view's render(), then the id is no longer there
Code:
this.get('container').get('id')  // is empty string
Anyone else notice this?

Thanks

Daniel Ji

  • Username: humblepie
  • Joined: Tue Feb 28, 2012 10:30 am
  • Posts: 147
  • GitHub: humblepie
  • Gists: humblepie
  • Offline
  • Profile

Re: YUI View - container attribute removes id

Post Posted: Thu Mar 29, 2012 6:34 pm
+0-
I'm using YUI 3.5pr4

Eric Ferraiuolo

YUI Developer

  • Username: ericf
  • Joined: Mon Jan 12, 2009 8:26 pm
  • Posts: 380
  • Location: Boston, MA
  • Twitter: ericf
  • GitHub: ericf
  • Gists: ericf
  • IRC: eric_f
  • YUI Developer
  • Offline
  • Profile

Re: YUI View - container attribute removes id

Post Posted: Thu Mar 29, 2012 7:24 pm
+0-
Can you point me to an example that reproduces this problem?

I tried out the code you have here and it worked correctly for me:
http://jsfiddle.net/ericf/SrLcW/

Daniel Ji

  • Username: humblepie
  • Joined: Tue Feb 28, 2012 10:30 am
  • Posts: 147
  • GitHub: humblepie
  • Gists: humblepie
  • Offline
  • Profile

Re: YUI View - container attribute removes id

Post Posted: Thu Mar 29, 2012 8:16 pm
+0-
Hi Eric,

Thanks for the quick response! False alarm. I thought it was a bug possibly due to using a YUI View in a YUI custom module, but it is not. I'm trying out TDD and turns out I was initializing the view in the setup() of my test case with a config object
Code:
Y.myCustomViewModule({
container: '#someSelectorThatDoesNotExist'
});
So even though I redefined the container inside the View class definition, the container was getting overridden by the container selector defined in the config object at construction! Once, I got rid of that it all works.

Now that I think of it, I guess I took one too many leaps and not enough baby steps w/ TDD :)

Thanks for the support!

Eric Ferraiuolo

YUI Developer

  • Username: ericf
  • Joined: Mon Jan 12, 2009 8:26 pm
  • Posts: 380
  • Location: Boston, MA
  • Twitter: ericf
  • GitHub: ericf
  • Gists: ericf
  • IRC: eric_f
  • YUI Developer
  • Offline
  • Profile

Re: YUI View - container attribute removes id

Post Posted: Thu Mar 29, 2012 8:20 pm
+0-
Oh good. That makes more sense that it wasn't working as expected because it was being overridden at the instance level.
  [ 5 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