コード例 #1
0
 /**
  * @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
0
    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
0
ファイル: AutoComplete.php プロジェクト: frostiks25/rzwebsys7
 /**
  * @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
0
ファイル: AjaxComplete.php プロジェクト: kissarat/tornados.su
 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();
 }