Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导模式作为jquery对象_Javascript_Jquery_Twitter Bootstrap_Modal Dialog_Bootstrap Modal - Fatal编程技术网

Javascript 引导模式作为jquery对象

Javascript 引导模式作为jquery对象,javascript,jquery,twitter-bootstrap,modal-dialog,bootstrap-modal,Javascript,Jquery,Twitter Bootstrap,Modal Dialog,Bootstrap Modal,使用引导模式的示例 <div class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><spa

使用引导模式的示例

<div class="modal fade">
  <div class="modal-dialog">
    <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">Modal title</h4>
      </div>
      <div class="modal-body">
        <p>One fine body&hellip;</p>
      </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><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
下一个问题是,如果模式已打开,如何创建克隆

我会猜的

var $theClone = $theModal.clone().init();

$theClone.title = "Title of the second modal";
$theClone.content = $.ajax(url);
$theClone.saveAction = saveTheContentOfTheContent;
$theClone.show();

这是可能的,还是我的假设完全错了?

你的想法还不错,但是

在html代码中可以有一个模式。 然后在标题所在的空间中,可以使用$scope类型

然后在js文件中,您可以在数组中指定所需的字符串,并在ng click函数的参数中更改为所需的字符串

index.html
你的想法很好,已经有人实施了。退房

此链接向您展示了您的想法可以使用的所有可能的案例场景。它还有一些我们甚至没有想到的巨大特性

var $theClone = $theModal.clone().init();

$theClone.title = "Title of the second modal";
$theClone.content = $.ajax(url);
$theClone.saveAction = saveTheContentOfTheContent;
$theClone.show();
<p>This is the modal view.</p>

<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">{{msgArray.title}}</h4>
        </div>
        <div class="modal-body">
          <p>{{msgArray.body}}</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">{{msgArray.btn}}</button>
        </div>
      </div>

    </div>
  </div>
var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
      $scope.msgArray1 = {
        title : "Modal 1",
        body: "This is the co to say anything you want here.",
        btn : "Close",
    };
     $scope.msgArray2 = {
        title : "Modal 2",
        body: "This is the co to say anything you want here.",
        btn : "Close",
    };

        $scope.msgTemp = {
        title : "",
        body: "",
        btn : "",
    };

    $scope.openModal = function(modal){

      if(modal == "modal1"){
        $scope.msgTemp = $scope.msgArray1;
      }
              if(modal == "modal2"){
        $scope.msgTemp = $scope.msgArray2;
      }

      $("#myModal").modal('show');

    }

});