使用CodeIgniter渲染到特定锚点的视图

In order to delete a person from the database, I would like to check its connections with other objects like inventories before deleting then display a bootstrap dialog message within the same page.

Using CodeIgniter, I have a page named "Person's details" that has a link to check these connections like so:

<a class="btn btn-custom" href="person/checkConnections/<?=$ID_Person?>">Delete</a>

In the controller "person", the method "checkConnections" looks like:

public function checkConnections($ID_Person)
{
  $data["strConnections"] = "3 connections with inventories found";
  $this->load->view("person/showdetails", $data)
  // launch the dialog box #deleteMsg
  ???
}

How can I launch the bootstrap dialog box which has an id="deleteMsg" and which is in the "Person's details" page? if it was an html url, the url would look like : http://mywebsite/person/showdetails/134#deleteMsg. But how can I have the same result using the codeIgniter method to render a view?

I can check these connections when loading the page the first time. But it wouldn't be efficient to do it every time since the delete action is rarely used.

You can use ajax to call the delete method and then show the response in a model form like below.

$('.btn-custom').click(function(e){
        var url = $(this).attr('href');
        $.ajax({
            type: 'GET',
            url: url,
            success: function(rtn)
            { 
                //load the bootstrap model setting the rtn as html content.
            }
          });
        return false;
    });

the controller should return the html output of your view.

public function checkConnections($ID_Person)
{
    $data["strConnections"] = "3 connections with inventories found";
    echo $this->load->view("person/showdetails", $data, true);
}

note the third parameter true of the view load method, this will return the output of the view.