Commit 5e9d3a8f by Antonio Ramirez

fix js formatting

parent ca7723e8
...@@ -63,17 +63,17 @@ class ActiveField extends \yii\widgets\ActiveField ...@@ -63,17 +63,17 @@ class ActiveField extends \yii\widgets\ActiveField
{ {
static $counter = 0; static $counter = 0;
$this->inputOptions['class'] .= ' typeahead-' . (++$counter); $this->inputOptions['class'] .= ' typeahead-' . (++$counter);
array_walk($data, function(&$item){ $item = array('word' => $item);}); foreach($data as &$item) {
$this->form->getView()->registerJs(<<<JS $item = array('word' => $item);
}
$this->form->getView()->registerJs("
var datum = new Bloodhound({ var datum = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.word);}, datumTokenizer: function(d){return Bloodhound.tokenizers.whitespace(d.word);},
queryTokenizer: Bloodhound.tokenizers.whitespace, queryTokenizer: Bloodhound.tokenizers.whitespace,
local: " . Json::encode($data) . " local: " . Json::encode($data) . "
}); });
datum.initialize(); datum.initialize();
jQuery('.typeahead-{$counter}').typeahead(null,{displayKey: 'word', source: datum.ttAdapter()}); jQuery('.typeahead-{$counter}').typeahead(null,{displayKey: 'word', source: datum.ttAdapter()});");
JS
);
return $this; return $this;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment