Search code examples
javascriptbackgrid

backgrid filter, custom template?


I am trying to change the of Backgrid.Extension.ClientSideFilter

template: _.template('<div class="input-prepend input-append"><span class="add-on"><i class="icon-search"></i></span><input type="text" <% if (placeholder) { %> placeholder="<%- placeholder %>" <% } %> name="<%- name %>" /><span class="add-on"><a class="close" href="#">&times;</a></span><span class="add-on"><div class="red" id="<%- idDivCantidadResultados %>"></div></span></div>'),

but i don't know how to change.


Solution

  • Just put it into the constructor.

    var filter = new Backgrid.Extension.ClientSideFilter({
      template: _.template("<...>",  /* Underscore template context */ {foo: bar}),
      collection: collection,
      fields: ['field']
    });
    

    http://underscorejs.org/#template