How about support dynamic DOM elements support in jLayout

25 views
Skip to first unread message

John

unread,
Nov 12, 2009, 4:00:18 AM11/12/09
to jLayout
Hi,

I found your awesome jLayout, it's really nice and easy to use, I have
tried your jquery.jlayout plugin also. But I found something
inconvenient.

In you demos:
<div id="parent">
<div id="child1"></div>
<div id="child2"></div>
<div id="child3"></div>
<div id="child4"></div>
</div>

then we can use grid layout to layout them
$("div#parent").layout({
type:"grid",
rows:2,
columns:2,
items:[$("div#child1"), , ,];
});

But I want to use js to generate my code dynamic. say in my script
I created

var con = $("<div></div>");
con.css({width:100, height:100});

then some children also, like the demo above.

then I try to

con.layout({
});

but nothing happen, I checked the code generated by jLayout, but
something like
`width:0px, height:0px` were found.

Could you please tell me what happend, or give any suggestion?

Thanks
John

Bram Stein

unread,
Nov 12, 2009, 4:39:29 AM11/12/09
to jla...@googlegroups.com
Hi,

You need to add your dynamically generated DOM nodes to the document
before jQuery's width and height methods return the values you set.
The jLayout jQuery plugin uses these methods to retrieve the width and
height for the elements it is called on, and they return 0 when the
elements are not part of the document.

Does that answer your question, or do you have some other requirements?

Best regards,

Bram

John

unread,
Nov 12, 2009, 7:15:23 AM11/12/09
to jLayout
Hi,

Yes!
That's exactly what I want, it works now, I was bothered when I do set
the width and height of my components, but always
get two zero. As you say, jQuery set the value only when the DOM nodes
appended to document, right?
Again, the jLayout is awesome! Actually, I'm try to implement a new UI
widgets collection. And the jLayout really helps me a lot.
So, pretty thanks.

Best regards,
John

On Nov 12, 5:39 pm, Bram Stein <b.l.st...@gmail.com> wrote:
> Hi,
>
> You need to add your dynamically generated DOM nodes to the document
> before jQuery's width and height methods return the values you set.
> The jLayout jQuery plugin uses these methods to retrieve the width and
> height for the elements it is called on, and they return 0 when the
> elements are not part of the document.
>
> Does that answer your question, or do you have some other requirements?
>
> Best regards,
>
> Bram
>

Bram Stein

unread,
Nov 12, 2009, 7:39:05 AM11/12/09
to jla...@googlegroups.com
Hi,

Good that it solves your problem. I am interested to see what you use
jLayout for. Could you provide a link to your project once you have
something online? Sounds interesting...

Bram

John

unread,
Nov 13, 2009, 7:42:05 AM11/13/09
to jLayout
Of course, once it done, I'll host it on code.gogole.com. Just wait,
^_^.

On Nov 12, 8:39 pm, Bram Stein <b.l.st...@gmail.com> wrote:
> Hi,
>
> >> > John- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages