My Ajax in select2 is not working in rails app. -


no error, results won't appear when key in ones exist in database. what's happening? help

slim file

  1. select box = select_tag "groups", nil, id: 'power-search', class: "select-example", multiple: true

2.javascript

    ajax: {       url: "/groups",       datatype: 'json',       delay: 250,       data: function (params) {         return {           q: params.term, // search term           page: params.page         };       },       processresults: function (data, params) {         // parse results format expected select2         // since using custom formatting functions not need         // alter remote json data, except indicate infinite         // scrolling can used         params.page = params.page || 1;          return {           results: data.items,           pagination: {             more: (params.page * 30) < data.total_count           }         };       },        cache: true      },x    }); 

controller

respond_to :html, :json    def index     @groups = group.all     render json: @groups   end 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -