Load Javascript for a widget Worpress
<p>I want to load a special Javascript File just when the widget is loaded in the sidebar. Where do I have to put my <code>wp_enqueue_script(...)</code> lines?</p>

<pre><code>class controller_widget extends WP_Widget {
    function controller_widget() {
        $this-&gt;color = "red";

        $this-&gt;dir = plugin_dir_url(__FILE__);
        $widget_ops = array('classname' =&gt; 'controller_widget', 'description' =&gt; __('Benutzerfreundlicher Controller zur eingrenzung von Objekten'));
        $control_ops = array('width' =&gt; 350, 'height' =&gt; 400);
        $this-&gt;WP_Widget('controller_widget', __('Controller'), $widget_ops, $control_ops);

        // At the moment I load the code here, but I want to proof that it is just loaded when the widget really is shown in the sidebar.
        }
    }

    function widget( $args, $instance ) {...}
}
</code></pre>

<p>Thank you!</p>
