表单自动完成

    public function rest()
    {
        $q = $this->request->get('q');
        $dicts = Db::name($this->table)->where('dvalue','like','%'.$q.'%')->field('dvalue')->select();
        return json(data2arr($dicts,'dvalue'));
    }

  

    require(['jqueryui1121', 'dragpanel'], function () {
        dragpanel.init();

        $('.packing').autocomplete({
            source: function( request, response ) {
                $.ajax({
                    url: '{:url("admin/dict/rest")}',
                    data: {
                        q: request.term
                    },
                    success: function( data ) {
                        response( data );
                    }
                });
            }
        });

    });

  

posted @ 2017-11-12 11:57 meetrice 阅读(...) 评论(...) 编辑 收藏