1. 程式人生 > >表單自動完成

表單自動完成

name ajax pack .ajax like pub req gpa tab

    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 );
                    }
                });
            }
        });

    });

  

表單自動完成