I am using backbone. I need to obtain an element's width inside the backbone render function. But unfortunately, that is not possible, because the element has not yet been added to the dom. Is there a way to obtain an element's width inide the backbone render function?
Asked
Active
Viewed 98 times
0
-
1nope. you need to place it first. its not backbones fault though -- its the dom – Javier Buzzi Apr 27 '16 at 14:54
1 Answers
0
You can't get the width without actually inserting the view to DOM, however, you can get the value by inserting it without the user seeing it by giving it negative z-index
, opacity:0
etc, something along this answer.
If you really really don't want to insert it in DOM for some reason, then you can make a hidden clone of it and insert that instead to find the dimensions.