something disturbing me since a while, jQuery API says :
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:
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
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:
<?php
class Test_Slider_Widget extends WP_Widget
{
public function form( $instance ) {
?>
<span id="test">Test</span>
<script>
jQuery(document).ready(function($) {
/* $('#test').on('click', function { //doesn't work
alert('test');
}); */
$('#test').live('click', function { //work
alert('test');
});
});
</script>
<?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