 <p>I'm surprised you had to ask, since it's basic Javascript, really... </p> <p>Since <code>press</code> is invoked from <code>oToggleButton</code>, the <code>this</code> keyword now holds a reference to <code>oToggleButton</code>, and <strong>not</strong> the controller (hence why the <code>getView()</code> method fails). Search for 'this keyword in inner function' for more info.</p> <p>To solve this, simply add a reference to this outside the inner function:</p> <p><code>var that = this;</code></p> <p>and in your inner function, use the reference instead:</p> <p><code>that.getView().addStyleClass("sapUiSizeCompact");</code></p>