Exemple #1
0
 /**
  * Registers the needed assets
  */
 public function registerAssets()
 {
     $view = $this->getView();
     TypeaheadBasicAsset::register($view);
     $this->registerPluginOptions('typeahead');
     $data = Json::encode(array_values($this->data));
     $dataVar = 'kvTypData_' . hash('crc32', $data);
     $view->registerJs("var {$dataVar} = {$data};", View::POS_HEAD);
     $this->dataset['name'] = $dataVar;
     if (!isset($this->dataset['source'])) {
         $this->dataset['source'] = new JsExpression('kvSubstringMatcher(' . $dataVar . ')');
     }
     $id = 'jQuery("#' . $this->options['id'] . '")';
     $dataset = Json::encode($this->dataset);
     $js = "{$id}.typeahead({$this->_hashVar}, {$dataset});";
     $view->registerJs($js);
     $this->registerPluginEvents($view);
 }
 /**
  * Registers the needed assets
  */
 public function registerAssets()
 {
     $view = $this->getView();
     TypeaheadBasicAsset::register($view);
     $this->registerPluginOptions('typeahead');
     $dataVar = str_replace('-', '_', $this->options['id'] . '_data');
     $view->registerJs('var ' . $dataVar . ' = ' . Json::encode(array_values($this->data)) . ';');
     $dataset = Json::encode(['name' => $dataVar, 'source' => new JsExpression('substringMatcher(' . $dataVar . ')')]);
     $view->registerJs('jQuery("#' . $this->options['id'] . '").typeahead(' . $this->_hashVar . ',' . $dataset . ');');
     $this->registerPluginEvents($view);
 }