Wordpress Widget jquery live() or on(), admin side

admin

Administrator
Staff member
something disturbing me since a while, jQuery API says :

Code:
As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers.

As I try to add some jquery stuff in my widget admin side ( <em>form() action of widget class</em> ), I was surprise to not be able to use on(), but live() to do the job.

So here is my question : <strong>Why and what am I misunderstanding ?</strong>

Regards, and of course, thx for your time.

ps I'm offcurse using >= 1.7 version.

Edit:

Code:
&lt;?php
    class Test_Slider_Widget extends WP_Widget 
        { 
            public function form( $instance ) { 
                ?&gt;
             &lt;span id="test"&gt;Test&lt;/span&gt;
             &lt;script&gt; 
             jQuery(document).ready(function($) {
                 /* $('#test').on('click', function { //doesn't work
                     alert('test'); 
                 }); */
                 $('#test').live('click', function { //work
                     alert('test');
                 });

             });
             &lt;/script&gt;


 &lt;?php }

EDIT 2: Ok, always use $this->get_field_id('id-text') to have a unique ID, or id will be duplicated cause of widget duplicated code in wordpress admin.
Thanks to <strong>Xec</strong> for showing me the way :)