muffin
muffin

Reputation: 2104

JQuery Catch onChange event of EditableField - datepicker

Hi i'm having a problem of catching event of an editable field.

I'm using Yii php, and i use the extension editablefield from x-editable.

$this->widget('ext.editable.EditableField', array(
    'type'      => 'date',
    'value' => $data->date_of_harvest,
    'model'     => $data,
    'htmlOptions'=>array(
        'id' => $data->id,
        'class' => 'harvest-datepicker',  
    ),
    'attribute' => 'date_of_harvest',
    'emptytext' => "<i class='icon-plus-sign'/></i><span>Add</span>"
));

Above is my widget - just a simple datepicker. However i can't seem to catch the change event of it. I tried below:

$(".harvest-datepicker").change(function(){

    console.log("test");
    var progenyId = $(this).attr('id');
    var value = $(this).val();

});

but that doesn't seem to do the trick. It doesnt even go inside the event function. Any help would do thanks!

Upvotes: 0

Views: 641

Answers (1)

Neeraj Kumar
Neeraj Kumar

Reputation: 1058

Jquery reads for first event only so what ever will be called firstly it will work and another call will not so you have to bind both the script on single event. There is no other way.

Upvotes: 1

Related Questions