Fixed register script

This commit is contained in:
Wanderson Braganca 2015-11-08 12:46:38 -02:00
parent 97fd3b72aa
commit d01ffd33f4
2 changed files with 4 additions and 1 deletions

View file

@ -3,6 +3,7 @@ yii2-fancytree-widget change Log
dev-master
----------
- Enh: Fixed register script
version 1.0.1

View file

@ -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");
}
}