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 14, 2012
1 parent 57ea6fe commit 37f294b
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
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,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 @@ -225,6 +226,9 @@
, href = $this.attr('href')
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
if(option == 'toggle') {
$.extend($target.data('modal').options, $this.data())
}

e.preventDefault()

Expand All @@ -236,4 +240,4 @@
})
})

}(window.jQuery);
}(window.jQuery);
7 changes: 6 additions & 1 deletion docs/assets/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,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 @@ -949,6 +950,9 @@
, href = $this.attr('href')
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
if(option == 'toggle') {
$.extend($target.data('modal').options, $this.data())
}

e.preventDefault()

Expand All @@ -960,7 +964,8 @@
})
})

}(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
Loading

0 comments on commit 37f294b

Please sign in to comment.