本文整理汇总了PHP中yii\jui\AutoComplete::init方法的典型用法代码示例。如果您正苦于以下问题:PHP AutoComplete::init方法的具体用法?PHP AutoComplete::init怎么用?PHP AutoComplete::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\jui\AutoComplete
的用法示例。
在下文中一共展示了AutoComplete::init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
Html::addCssClass($this->options, 'form-control');
if (!array_key_exists('onfocus', $this->options)) {
$this->options['onfocus'] = 'jQuery(this).autocomplete(\'search\');';
}
$this->clientOptions = array_merge($this->clientOptions, ['source' => $this->source, 'minLength' => $this->minLength]);
}
示例2: init
public function init(){
$this->clientOptions =[
'source' => $this->url,
'minLength' => 1,
'select' => new JsExpression('function(event, data) {$("#'.$this->id.'").val(data.item.name);$(this).attr("data-id",data.item.id);return false;}'),
'focus' => new JsExpression('function(event,data){$(this).val(data.item.name);$(this).attr("data-id",data.item.id);return false;}'),
];
$this->renderItem = new JsExpression('.autocomplete("instance")._renderItem = function( ul, item ) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.name + "<br><img src =" + "http://localhost/Auction/auction/web/uploads/products/thumbs/index1441177480.jpeg" + "></img></a>")
.appendTo(ul);
};'
);
parent::init();
}
示例3: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!isset($this->visibleOptions["id"])) {
$this->visibleOptions["id"] = $this->options["id"] . "-visible";
}
if (empty($this->clientOptions['select'])) {
$this->clientOptions['select'] = new JsExpression("function(event, ui) {\n\n var hiddenVal = ui.item.id ? ui.item.id : ui.item.value;\n\n \$('#{$this->options["id"]}').val(hiddenVal);\n\n }");
}
if (empty($this->clientOptions['change'])) {
$this->clientOptions['change'] = new JsExpression("function(event, ui) {\n\n var val = \$(event.currentTarget).val();\n\n if(!val)\n \$('#{$this->options["id"]}').val('');\n\n }");
}
if ($this->liveSync) {
$this->view->registerJs("\n\n \$('#{$this->visibleOptions["id"]}').on('keyup', function(){\n\n \$('#{$this->options["id"]}').val(\$(this).val());\n\n });\n\n ");
}
if ($this->hasModel() and $this->visibleAttribute === null) {
$this->visibleAttribute = $this->attribute;
} elseif ($this->visibleValue === null) {
$this->visibleValue = $this->value;
}
}
示例4: init
public function init()
{
$url = Url::to($this->route);
$this->clientOptions['source'] = new JsExpression("function(request, response) {\n \$.getJSON('{$url}', {\n search: request.term\n }, response);\n }");
parent::init();
}