Commit 82ea5847 authored by Jacob Thornton's avatar Jacob Thornton
Browse files

adds remote source to modal. Remote source can be specified in href or by...

adds remote source to modal. Remote source can be specified in href or by providing a remote option #936
parent 041b8bdf
Showing with 30 additions and 10 deletions
+30 -10
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
this.options = options this.options = options
this.$element = $(content) this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
} }
Modal.prototype = { Modal.prototype = {
...@@ -215,9 +216,10 @@ ...@@ -215,9 +216,10 @@
$(function () { $(function () {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this), href var $this = $(this)
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 , href = $this.attr('href')
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data()) , $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())
e.preventDefault() e.preventDefault()
$target.modal(option) $target.modal(option)
......
...@@ -755,6 +755,7 @@ ...@@ -755,6 +755,7 @@
this.options = options this.options = options
this.$element = $(content) this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
} }
Modal.prototype = { Modal.prototype = {
...@@ -940,9 +941,10 @@ ...@@ -940,9 +941,10 @@
$(function () { $(function () {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this), href var $this = $(this)
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 , href = $this.attr('href')
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data()) , $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())
e.preventDefault() e.preventDefault()
$target.modal(option) $target.modal(option)
......
This diff is collapsed.
...@@ -269,6 +269,13 @@ ...@@ -269,6 +269,13 @@
<td>true</td> <td>true</td>
<td>Shows the modal when initialized.</td> <td>Shows the modal when initialized.</td>
</tr> </tr>
<tr>
<td>remote</td>
<td>path</td>
<td>false</td>
<td><p>If a remote url is provided, content will be loaded via jQuery's <code>load</code> method and injected into the <code>.modal-body</code>. If you're using the data api, you may alternatively use the <code>href</code> tag to specify the remote source. An example of this is shown below:</p>
<pre class="prettyprint linenums"><code>&lt;a data-toggle="modal" href="remote.html" data-target="#modal"&gt;click me&lt;/a&gt;</code></pre></td>
</tr>
</tbody> </tbody>
</table> </table>
<h3>Markup</h3> <h3>Markup</h3>
......
...@@ -191,6 +191,13 @@ ...@@ -191,6 +191,13 @@
<td>{{_i}}true{{/i}}</td> <td>{{_i}}true{{/i}}</td>
<td>{{_i}}Shows the modal when initialized.{{/i}}</td> <td>{{_i}}Shows the modal when initialized.{{/i}}</td>
</tr> </tr>
<tr>
<td>{{_i}}remote{{/i}}</td>
<td>{{_i}}path{{/i}}</td>
<td>{{_i}}false{{/i}}</td>
<td><p>{{_i}}If a remote url is provided, content will be loaded via jQuery's <code>load</code> method and injected into the <code>.modal-body</code>. If you're using the data api, you may alternatively use the <code>href</code> tag to specify the remote source. An example of this is shown below:{{/i}}</p>
<pre class="prettyprint linenums"><code>&lt;a data-toggle="modal" href="remote.html" data-target="#modal"&gt;click me&lt;/a&gt;</code></pre></td>
</tr>
</tbody> </tbody>
</table> </table>
<h3>{{_i}}Markup{{/i}}</h3> <h3>{{_i}}Markup{{/i}}</h3>
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
this.options = options this.options = options
this.$element = $(content) this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
} }
Modal.prototype = { Modal.prototype = {
...@@ -215,9 +216,10 @@ ...@@ -215,9 +216,10 @@
$(function () { $(function () {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this), href var $this = $(this)
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 , href = $this.attr('href')
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data()) , $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())
e.preventDefault() e.preventDefault()
$target.modal(option) $target.modal(option)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment