Jump To …
backend.ckan.js backend.couchdb.js backend.csv.js backend.dataproxy.js backend.elasticsearch.js backend.gdocs.js backend.memory.js data.transform.js ecma-fixes.js model.js view.graph.js view.grid.js view.map.js view.multiview.js view.slickgrid.js view.timeline.js view.transform.js widget.facetviewer.js widget.fields.js widget.filtereditor.js widget.pager.js widget.queryeditor.js

# widget.queryeditor.js

¶

    /*jshint multistr:true */

    this.recline = this.recline || {};
    this.recline.View = this.recline.View || {};

    (function($, my) {

    my.QueryEditor = Backbone.View.extend({
      className: 'recline-query-editor',
      template: ' \
        <form action="" method="GET" class="form-inline"> \
          <div class="input-prepend text-query"> \
            <span class="add-on"><i class="icon-search"></i></span> \
            <input type="text" name="q" value="{{q}}" class="span2" placeholder="Search data ..." class="search-query" /> \
          </div> \
          <button type="submit" class="btn">Go &raquo;</button> \
        </form> \
      ',

      events: {
        'submit form': 'onFormSubmit'
      },

      initialize: function() {
        _.bindAll(this, 'render');
        this.el = $(this.el);
        this.model.bind('change', this.render);
        this.render();
      },
      onFormSubmit: function(e) {
        e.preventDefault();
        var query = this.el.find('.text-query input').val();
        this.model.set({q: query});
      },
      render: function() {
        var tmplData = this.model.toJSON();
        var templated = Mustache.render(this.template, tmplData);
        this.el.html(templated);
      }
    });

    })(jQuery, recline.View);