Javascript 引导模式仅在第二次调用时显示

Javascript 引导模式仅在第二次调用时显示,javascript,php,jquery,angularjs,twitter-bootstrap,Javascript,Php,Jquery,Angularjs,Twitter Bootstrap,当我第一次调用该函数时,什么也没发生,但在第二次单击时,它工作正常。随后单击时,将显示上一次单击的结果。下面是我的代码 <table class="table"> <thead> <tr class="text-center" style="font-weight: bold"> <td></td> <td>Name</td>

当我第一次调用该函数时,什么也没发生,但在第二次单击时,它工作正常。随后单击时,将显示上一次单击的结果。下面是我的代码

 <table class="table">

        <thead>
        <tr class="text-center" style="font-weight: bold">
            <td></td>
            <td>Name</td>
            <td>ID</td>
            <td>Age</td>
            <td>Registered On</td>
            <td>View Prescription</td>
        </tr>
        </thead>
        <tr ng-repeat="x in patientList | filter:filter_patient_list" class="text-center">
            <td>{{x.list}}</td>
            <td>{{x.name}}</td>
            <td>{{x.patient_id}}</td>
            <td>{{x.age}}</td>
            <td>{{x.date_registered}}</td>
            <td><button data-toggle="modal"  data-target="#view_prescription_from_patient_list{{x.patient_id}}" ng-click="getPrescriptionModal(x.patient_id)">/button></td>

        </tr>

    </table>
和我的php代码来获取模态窗口

    if($get_what == "prescription_list_for_patient_list")
{

    $patient_id = $_GET['patient_id'];
echo"
<div class='modal fade' id='view_prescription_from_patient_list$patient_id' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>
  <div class='modal-dialog' role='document'>
    <div class='modal-content'>
      <div class='modal-header'>
        <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
        <h4 class='modal-title' id='myModalLabel'>Modal title</h4>
      </div>
      <div class='modal-body'>
        ...
      </div>
      <div class='modal-footer'>
        <button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
        <button type='button' class='btn btn-primary'>Save changes</button>
      </div>
    </div>
  </div>
</div>
";
if($get\u what==“处方清单”\u用于患者清单”)
{
$patient\u id=$\u GET['patient\u id'];
回声“
&时代;
情态标题
...
接近
保存更改
";

我尝试用Jquery调用Ajax,但也遇到了同样的问题。

似乎您试图在DOM中存在模式之前打开它

首先尝试将响应附加到
,以便用于搜索它的选择器将存在

如果您使用的ID仍然仅在响应html中,则使用
$(“#ID')
搜索现有的DOM元素,因此不会找到它

$http.get(url, function(response){
    $('body').append(response);
    $(selector).modal();
});
或者你也可以试试

$(response).modal();
我不确定bootstrap是否会自动将响应附加到DOM,或者不这样做


同时强烈建议去掉bootstrap.js并使用angular ui bootstrap指令。

我曾尝试附加到body并使用angular ui bootstrap指令,但仍然存在相同的错误是否有任何方法可以在body load上加载modal并在单击时获取特定项目的详细信息?不确定您的意思…我个人倾向于使用一个情态动词及其内容的变化
$(response).modal();