Skip to content

Commit

Permalink
Allow passing data arguments to modal (fixes twbs#531)
Browse files Browse the repository at this point in the history
Implements @bronson's suggestion, all credit to him.
  • Loading branch information
kynan committed Aug 2, 2012
1 parent 857b8fb commit 2f3d04b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion docs/assets/js/bootstrap-modal.js
Expand Up @@ -187,6 +187,7 @@
, data = $this.data('modal')
, options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('modal', (data = new Modal(this, options)))
else $.extend($this.data('modal').options, option)
if (typeof option == 'string') data[option]()
else if (options.show) data.show()
})
Expand All @@ -209,10 +210,13 @@
var $this = $(this), href
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
if(option == 'toggle') {
$.extend($target.data('modal').options, $this.data())
}

e.preventDefault()
$target.modal(option)
})
})

}(window.jQuery);
}(window.jQuery);
7 changes: 6 additions & 1 deletion docs/assets/js/bootstrap.js
Expand Up @@ -854,6 +854,7 @@
, data = $this.data('modal')
, options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('modal', (data = new Modal(this, options)))
else $.extend($this.data('modal').options, option)
if (typeof option == 'string') data[option]()
else if (options.show) data.show()
})
Expand All @@ -876,13 +877,17 @@
var $this = $(this), href
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
if(option == 'toggle') {
$.extend($target.data('modal').options, $this.data())
}

e.preventDefault()
$target.modal(option)
})
})

}(window.jQuery);/* ===========================================================
}(window.jQuery);
/* ===========================================================
* bootstrap-tooltip.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#tooltips
* Inspired by the original jQuery.tipsy by Jason Frame
Expand Down

0 comments on commit 2f3d04b

Please sign in to comment.