Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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 在引导确认模式中控制确认按钮_Javascript_Jquery_Angularjs_Twitter Bootstrap_Bootstrap Modal - Fatal编程技术网

Javascript 在引导确认模式中控制确认按钮

Javascript 在引导确认模式中控制确认按钮,javascript,jquery,angularjs,twitter-bootstrap,bootstrap-modal,Javascript,Jquery,Angularjs,Twitter Bootstrap,Bootstrap Modal,我把这个例子改成了一个简单的例子。当我点击“删除这个{{item.id}}”按钮时,我想调用一个delete函数。标题已成功获取item.id值 <h4 class="modal-title" id="exampleModalLabel">Do you want to remove {{item.id}}</h4> 是否要删除{{item.id} 但是按钮没有获得item.id值,函数也不起作用。而不是“Remove this item.id”,它只是“Remove

我把这个例子改成了一个简单的例子。当我点击“删除这个{{item.id}}”按钮时,我想调用一个delete函数。标题已成功获取item.id值

<h4 class="modal-title" id="exampleModalLabel">Do you want to remove  {{item.id}}</h4>
是否要删除{{item.id}
但是按钮没有获得item.id值,函数也不起作用。而不是“Remove this item.id”,它只是“Remove this”,函数也不获取参数

<button type="button" id="exampleModalLabel" class="btn btn-primary" ng-click="removeItem(item.id)">Remove this {{item.id}}</button>
删除此{{item.id}
我所拥有的是:

<tr ng-repeat="item in items">
    <td>{{item.id}}</td>
    <td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="{{item.id}}">Remove this item?</button></td>
</tr>
<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">Do you want to remove  {{item.id}}</h4>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" ng-click="removeItem(item)">Remove this {{item.id}}</button>
      </div>
    </div>
  </div>
</div>

//And this javascript
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var recipient = button.data('whatever');
var modal = $(this);
modal.find('.modal-title').text('New message to ' + recipient);
modal.find('.modal-body input').val(recipient);
});

{{item.id}
是否删除此项目?
&时代;
是否要删除{{item.id}
接近
删除此{{item.id}
//这个javascript
$('exampleModal').on('show.bs.modal',函数(事件){
var按钮=$(event.relatedTarget);
var recipient=button.data('whatever');
var modal=$(本);
modal.find('.modal title').text('发送给'+收件人的新邮件');
modal.find('.modal body input').val(收件人);
});

我希望这些信息足够了。如果您需要更多信息,请告诉我。

您的模式超出了
项目的范围。您需要将
分配给控制器内的某个温度变量。您应该使用
ng click
来实现这一点,类似于
ng click=“tempItem=item”
。您可能还必须编辑
removietem
函数

<tr ng-repeat="item in items">
    <td>{{item.id}}</td>
    <td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="{{item.id}}" ng-click="tempItem = item">Remove this item?</button></td>
</tr>
<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">Do you want to remove  {{tempItem.id}}</h4>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" id="exampleModalLabel" class="btn btn-primary" ng-click="removeItem(tempItem)">Remove this {{tempItem.id}}</button>
      </div>
    </div>
  </div>
</div>

//And this javascript
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var recipient = button.data('whatever');
var modal = $(this);
modal.find('.modal-title').text('New message to ' + recipient);
modal.find('.modal-body input').val(recipient);
});

{{item.id}
是否删除此项目?
&时代;
是否要删除{{tempItem.id}
接近
删除此{{tempItem.id}
//这个javascript
$('exampleModal').on('show.bs.modal',函数(事件){
var按钮=$(event.relatedTarget);
var recipient=button.data('whatever');
var modal=$(本);
modal.find('.modal title').text('发送给'+收件人的新邮件');
modal.find('.modal body input').val(收件人);
});
尝试使用以下方法:

<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    <button type="button" id="removeButton" class="btn btn-primary">Remove this <span id="itemid"></span></button>
</div>

//JS
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var recipient = button.data('whatever');
var modal = $(this);
modal.find('.modal-title').text('New message to ' + recipient);
modal.find('.modal-body input').val(recipient);

modal.find('#itemid').html(recipient); // add this
modal.find('#removeButton').attr('ng-click', 'removeItem('+recipient+')'); // add this
});

接近
去掉这个
//JS
$('exampleModal').on('show.bs.modal',函数(事件){
var按钮=$(event.relatedTarget);
var recipient=button.data('whatever');
var modal=$(本);
modal.find('.modal title').text('发送给'+收件人的新邮件');
modal.find('.modal body input').val(收件人);
modal.find('#itemid').html(收件人);//添加此
modal.find('#removeButton').attr('ng-click','removietem('+recipient+'));//添加此
});

removeItem(item.id)不应该是removeItem({{item.id}})吗?不,相同的结果。。。它甚至不能在innerHTML上显示…模式是否出现在屏幕上?您可以通过javascript设置值来解决问题。在JS:var item={{item.id}}中设置值;然后在函数中为modal:modal.find('.modal body button').attr(“ng click”,“removietem”(+item+)))@Paulmordan我试过了,但它仍然不起作用…即使modal没有项目,它仍然能够在
中获取item.id
是否要删除{{item.id}
为什么它在
中无法获取它删除这个{item.id}
我认为它无法在
h4
中获取
item.id
,您只需使用jquery
modal.find('.modal title').text('发送给'+收件人的新邮件')更改
h4
内容