Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you pass <code>this</code> to the <code>popup</code> object, you are passing the element itself (which I believe is your intention). However, elements don't by default have a property called <code>width</code>.</p> <p>Perhaps you are looking for <code>getSize();</code>? This returns a two-property object (<code>x</code> and <code>y</code>), corresponding respectively to the width and height of the element.</p> <p>I've approximated your code into the following jsFiddle, give it a try: <a href="http://jsfiddle.net/g4SmJ/" rel="nofollow">http://jsfiddle.net/g4SmJ/</a></p> <p>For reference, here is the new <code>Popup</code> class code:</p> <pre><code>var Popup = new Class({ initialize : function(){ }, open : function(tile) { size = tile.getSize(); console.log(size); // console.log provides a nicer interface for debugging, you can pass objects into it! Use the Chrome Inspector or Firebug to see its output. alert(size.x); } }); </code></pre> <hr> <p>In response to your comment:</p> <blockquote> <p>Oh ups I did not meant to alert the doms width, sorry for that. What I posted is smaller code from the full object. Width actually was a defined member in Tiles that I wanted to alert out of Popup</p> </blockquote> <p>In this case, then when you are sending the call to <code>.open();</code>, you passed <code>this</code> into the function call, but <em>you are not passing the <code>Tile</code> object</em>! Instead, you passed the <code>inner</code> element you created.</p> <p>Rewrite <code>Tile</code> thusly:</p> <pre><code>var Tile = new Class({ initialize : function(){ var self = this; this.inner = new Element(...); this.inner.addEvent('click', function() { popup.open(self); }); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload