title: Best approach to avoid javascript's “this” mistakes in XBL
body: <p>Talking about XBL is not exactly talking about javascript. So I'll create this question that's related to <a href="https://stackoverflow.com/questions/4520243/best-approach-to-avoid-javascripts-this-mistakes">this one</a>, but now about XBL, where I'm not the creator of the root javascript code, but just of the methods and event handlers inside the bindings.</p>
  
  <p>--</p>
  
  <p>In some cases, the <code>this</code> keyword may not refer to the object I expect it to. (recent example: <a href="https://stackoverflow.com/questions/4499500/calling-a-method-from-xbl/4510486#4510486">in an key event, in my XBL)</a></p>
  
  <p>What's the best approach to avoid this kind of mistake?</p>
  
  <p>For now, I'm using always the <code>getElementById</code> (or <code>$.fn</code> from jQuery), but I'm not sure if it's the best approach.</p>
  
  <p><strong>--update</strong></p>
  
  <p>A little bit more details:</p>
  
  <p>Within a <a href="https://developer.mozilla.org/en/XUL_Tutorial:Adding_Methods_to_XBL-defined_Elements" rel="nofollow noreferrer">XBL method</a> the only way to access the element that was defined in the <a href="https://developer.mozilla.org/en/XUL" rel="nofollow noreferrer">Xul</a> file (the GUI description file) without using "this" (as it may not be the "this" I expect) is with getElementById, and this makes the code not reusable, so I'm looking for alternatives..</p>