簡體   English   中英

Bootstrap模式在實時服務器上不起作用

[英]Bootstrap modal doesn't work on live server

觸發按鈕:

while ($row = mysqli_fetch_array($result)) {
        $name = $row['name'];
        $id = $row['id'];
        echo '<a data-target="#exampleModal" class="wpmui-field-input button wpmui-submit button-primary" data-toggle="modal" data-whatever="'.$name.'">Details</a>';
        echo $id . "<br>";
    }  

莫代爾:

echo'
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
  <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="exampleModalLabel">New message</h4>
      </div>
      <div class="modal-body">
        <form>
          <textarea class="form-control"></textarea>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Send message</button>
      </div>
    </div>
  </div>
</div>';

JavaScript的:

echo'
<script type="text/javascript">
    window.onload = function () { 
        $("#exampleModal").on("show.bs.modal", function (event) {
  var button = $(event.relatedTarget) // Button that triggered the modal
  var recipient = button.data("whatever") // Extract info from data-* attributes
  var modal = $(this)
  modal.find(".modal-title").text("New message to " + recipient)
  modal.find(".modal-body textarea").val(recipient)
})
     }
</script>';  

現在我上面的所有這些代碼都會在點擊觸發按鈕時生成一個模態框。 此代碼似乎在我的localhost中正常工作,但它在我的服務器中的行為不同,並且返回的值undefined 現在,我認為它可能與PHP版本有關,因為我的localhost有PHP7而我的服務器有PHP5。 這是否意味着在PHP5中不支持<textarea>標記中的值字段(JavaScript是.val() ),如<textarea value="something">

即使是這種情況,這個問題的解決方法是什么? 我嘗試使用.html().text()但它只是覆蓋了值,當你再次打開模態框時,所有模態框的值都是相同的(而它應該是不同的值)每個收件人模態框)。

看來你還沒有包含必要的jquery和樣式files.try包括bootstrap.js,jQuery.min.js這個可能對你有幫助www.bootply.com/mRbjbQ1JAB祝你好運。

使用chrome開發人員工具或在firefox中,具體取決於您的瀏覽器,單擊網絡選項卡並加載模式應顯示的頁面,檢查開發人員工具的網絡選項卡中列出的所有文件,以查找未找到404的人,這可能是什么東西少了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM