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