Fixed register script
This commit is contained in:
parent
97fd3b72aa
commit
d01ffd33f4
|
@ -3,6 +3,7 @@ yii2-fancytree-widget change Log
|
||||||
|
|
||||||
dev-master
|
dev-master
|
||||||
----------
|
----------
|
||||||
|
- Enh: Fixed register script
|
||||||
|
|
||||||
|
|
||||||
version 1.0.1
|
version 1.0.1
|
||||||
|
|
|
@ -40,13 +40,15 @@ class FancytreeWidget extends \yii\base\Widget
|
||||||
$view = $this->getView();
|
$view = $this->getView();
|
||||||
FancytreeAsset::register($view);
|
FancytreeAsset::register($view);
|
||||||
$id = 'fancyree_' . $this->id;
|
$id = 'fancyree_' . $this->id;
|
||||||
|
|
||||||
if (isset($this->options['id'])) {
|
if (isset($this->options['id'])) {
|
||||||
$id = $this->options['id'];
|
$id = $this->options['id'];
|
||||||
unset($this->options['id']);
|
unset($this->options['id']);
|
||||||
} else {
|
} else {
|
||||||
echo Html::tag('div', '', ['id' => $id]);
|
echo Html::tag('div', '', ['id' => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = Json::encode($this->options);
|
$options = Json::encode($this->options);
|
||||||
$view->registerJs('$("#' . $id . '").fancytree( ' .$options .')');
|
$view->registerJs("\n\$(\"#{$id}\").fancytree({$options});\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue