Skip to content

Commit

Permalink
Gets widget injection tests passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmcclure committed Oct 14, 2014
1 parent eb11394 commit e96cec8
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions views/shared/javascripts/src/shared/widget/widget.view.js
Expand Up @@ -16,14 +16,40 @@ Neatline.module('Shared.Widget', function(Widget) {


/**
* TODO|bandaid
* Inject the widget container into the map.
* Try to attach the view to an existing element, identified by the `id`
* attribute on the class definition.
*
* @param {Object} options
*/
constructor: function(options) {

options = options || {};

// Attach the view to existing element.
var el = $('#'+this.id);
if (el.length) options.el = el;

Widget.View.__super__.constructor.call(this, options);

},


/**
* Ensure that the container element is appended to the DOM.
*
* @param {Object} options
*/
initialize: function(options) {
this.$el.appendTo($('#neatline-map'));

options = options || {};

// Inject the container, if it isn't already in the DOM.
if (!$.contains(document, this.el)) {
this.$el.appendTo($('#neatline-map'));
}

Widget.View.__super__.initialize.call(this, options);

},


Expand Down

0 comments on commit e96cec8

Please sign in to comment.