Sha256: 924b9d88e595b3fff545577ad4a775f23014b07278fb95b42dd1688864857657

Contents?: true

Size: 886 Bytes

Versions: 3

Compression:

Stored size: 886 Bytes

Contents

// URL field
//
// This shouldn’t be instantiated directly.
// Instead, use `{{urlField}}` like this:
//
//     {{urlField field="example"}}
//
slices.UrlFieldView = Backbone.View.extend({

  // -- Config --

  tagName: 'input',
  className: 'url-field',

  attributes: {
    'type': 'text',
    'data-store': '/admin/pages/search.json?query=:query',
    'data-template': '#livefield-result-template'
  },

  // -- Init --

  initialize: function() {
    _.bindAll(this);
    if (this.options.autoAttach) _.defer(this.attach);
  },

  // -- Rendering --

  placeholder: function() {
    return Handlebars.compile('<div id="placeholder-{{id}}"></div>')(this);
  },

  attach: function() {
    $('#placeholder-' + this.id).replaceWith(this.el);
    $(this.el).val(this.options.value);
    this.render();
  },

  render: function() {
    $(this.el).livefield();
    return this;
  }
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slices-2.0.2 app/assets/javascripts/slices/app/views/url_field_view.js
slices-2.0.1 app/assets/javascripts/slices/app/views/url_field_view.js
slices-2.0.0 app/assets/javascripts/slices/app/views/url_field_view.js