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;?>"
5
  • getbootstrap.com/javascript/#via-javascript Commented Jul 13, 2017 at 8:39
  • Possible duplicate of How to open a Bootstrap modal window using jQuery? Commented Jul 13, 2017 at 8:39
  • I need to pass $id value! Commented Jul 13, 2017 at 9:26
  • 1
    Not sure that warranted an !, but check the documentation link provided. $('#editBox').modal({remote: url + "?id=" + id, show:true}) or just use ajax to load the content. Commented Jul 13, 2017 at 9:35
  • yeeeeeeesss :)) Thanks a lot..... !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Commented Jul 13, 2017 at 9:48

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.