Closed re1naldo closed 7 years ago
You need to set the clientEvents
not clientOptions
: https://github.com/2amigos/yii2-editable-widget/blob/master/src/Editable.php#L79
PS: Very sorry for the really, really late response.
I have the same issue. I do use ClientEvents, but the handler is not attached to the object. On the editable in a detail view, it does work as expected, but not on editableColumn. Does anybody have a working example?
echo GridView::widget([
'dataProvider' => $model,
'summary' => '',
'columns' => [
[
'class' => EditableColumn::className(),
'attribute' => 'field_id',
'value' => 'field.name',
'url' => 'import-parser/editable', // the route to the editable action!
'type' => 'text',
'editableOptions' => [
'mode' => 'inline',
'value' => 'field.name',,
'clientEvents' => [
'save' => new \yii\web\JsExpression('function(response, newValue) {
alert("asdf");
}')
]
]
] ... //other columns to follow here....
@tonydspaniard I have just checked your source and it looks like the clientOptions are ignored. I made a hack of it:
Adding this into registerClientScript:
if (!empty($this->clientEvents)) {
$js = [];
foreach ($this->clientEvents as $event => $handler) {
$js[] = "jQuery('$selector').on('$event', $handler);";
}
$view->registerJs(implode("\n", $js));
}
So I have chosen to make ClientEvent separate from EditableOptions, because this makes it more consistent with how the editableWidget of you is working. There you have clientOptions and clientEvents separated as well. I have tested it and it works for me. Please let me know what you think of it.
Thanks again for all your extensions ! gb5256
How to setup
success
callback for Editable when we use EditableColumn? I tried:but the
success
callback was not fired. I also tried withoutclientOptions
and got the same result.