0

Get element by jQuery with widget ID and html ID

asked 2013-12-12 12:03:20 +0800

askar gravatar image askar
0 1

updated 2013-12-13 05:51:22 +0800

Hello everyone! I am trying to get width and height of the <center> element of the <borderlayout> element for scaling SVG. For this task i am using jQuery and trying to get <div> with CSS class z-center, but it returns null. When i used ZK 6.5.3 it works well, but when i updated to ZK 7.0.0 it stops work.

This is my code:

...
<n:script xmlns:n="native"><![CDATA[
function autoScale() {
      var width_center = $('$centerLayout .z-center').width();
      var height_center = $('$centerLayout .z-center').height();
      $('svg').attr('width', width_center);
      $('svg').attr('height', height_center);
    }
    ]]></n:script>
...
<center id="centerLayout" autoscroll="true">
  <div id="SVGBox" align="center" vflex="1" style="overflow: auto;">
    <label id="schemeName" value="Object Name" style="font-size: large; display: block;"/>
    <html id="SVGConteiner" vflex="1" />
  </div>
</center>
...

Why it started return null for variables width_center and height_center? Very interesting thing is that if i write:

var width_center = $('$centerLayout .z-div').width();

it will work fine, and return width of the <div> element with id="SVGBox"

Updated:

I finded one solution:

var center = $('$centerLayout').find('.z-center');
var width_center = center.width();

But, when i saw in IE console like this

for (var i in center ) {
  console.log(i + ":" + center [i]);
}

I saw that selector for this object is $centerLayout .z-center. But i can't get that object with this selector. So:

var center = $('$centerLayout .z-center');

is not the same for:

var center = $('$centerLayout').find('.z-center');

Is this a bug, or i doing something wrong?

delete flag offensive retag edit

Comments

The center can be matched by another selector $('$centerLayout.z-center'). I will figure it out and give a more detailed explanation in a couple of days. Thanks for your asking!

RaymondChao ( 2013-12-13 16:02:01 +0800 )edit

Hello askar, this is a bug. I have post an tracker here. Thanks again for your reporting.

RaymondChao ( 2013-12-17 02:36:52 +0800 )edit

I finded that this bug appears not only for center element, but for north and west too.

askar ( 2013-12-17 03:16:48 +0800 )edit

Yes, it is. Sorry for the inconvenience.

RaymondChao ( 2013-12-17 09:05:17 +0800 )edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-12-12 12:03:20 +0800

Seen: 88 times

Last updated: Dec 13 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More