Skip to content

Commit

Permalink
allow options.content to be a function returning html that is called …
Browse files Browse the repository at this point in the history
…on each open
  • Loading branch information
lincolndbryant committed Oct 28, 2014
1 parent 0cad0b8 commit 195fa0e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
7 changes: 6 additions & 1 deletion coffee/drop.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ createContext = (options={}) ->

@content = document.createElement 'div'
addClass @content, "#{ drop.classPrefix }-content"
if typeof @options.content is 'object'

if typeof @options.content is 'function'
@content.innerHTML = @options.content.call(@, @)
@on 'open', =>
@content.innerHTML = @options.content.call(@, @)
else if typeof @options.content is 'object'
@content.appendChild @options.content
else
@content.innerHTML = @options.content
Expand Down
8 changes: 7 additions & 1 deletion drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -1588,14 +1588,20 @@ return this.Tether;
};

DropInstance.prototype.setupElements = function() {
var _this = this;
this.drop = document.createElement('div');
addClass(this.drop, drop.classPrefix);
if (this.options.classes) {
addClass(this.drop, this.options.classes);
}
this.content = document.createElement('div');
addClass(this.content, "" + drop.classPrefix + "-content");
if (typeof this.options.content === 'object') {
if (typeof this.options.content === 'function') {
this.content.innerHTML = this.options.content.call(this, this);
this.on('open', function() {
return _this.content.innerHTML = _this.options.content.call(_this, _this);
});
} else if (typeof this.options.content === 'object') {
this.content.appendChild(this.options.content);
} else {
this.content.innerHTML = this.options.content;
Expand Down
Loading

0 comments on commit 195fa0e

Please sign in to comment.