0

In my html page, now I open modal dialog in this way

Modal Call button

<a class="btn btn-primary btn-xs" data-toggle="modal" data-target="#editBox" href="file.php?id=<?php echo $obj->id;?>">

The following html code in page

<div class="modal fade" id="editBox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
          //Content Will show Here
        </div>
    </div>
</div>

And this is file.php

<?php
$Id = $_GET["id"];
?>
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">&times;</button>
    <h4 class="modal-title"><center>Heading</center></h4>
</div>
<div class="modal-body">
    //Show records fetched from database against $Id
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default">Submit</button>
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>

What if I need to call the modal through script function ?

I have this

eventClick: function (result) {

   // call the dialog passing $id
})

EDIT

I need to pass $id value

Now I call the dialog with

href="file.php?id=<?php echo $obj->id;?>"
FireFoxII
  • 828
  • 4
  • 18
  • 31

1 Answers1

2

You can specify the url to load when opening the modal with the remote option:

$('#editBox').modal({
    remote: url + "?id=" + id, 
    show: true
});

The current recommendation is to use ajax to load the content rather than use the remote: option - this will be removed in later versions of bootstrap.

Source: http://getbootstrap.com/javascript/#via-javascript

freedomn-m
  • 27,664
  • 8
  • 35
  • 57