简体   繁体   English

禁用重复div内的所有按钮

[英]disable all buttons inside a repeating div

So i have a Jquery template that display multiple results to the user, at the bottom of the results is a div which i am using to store some buttons. 所以我有一个Jquery模板,向用户显示多个结果,结果的底部是一个div,我用来存储一些按钮。

Now, depending on the status of a record, i want to hide all buttons within the e div's, but for some reason, the following does nothing: 现在,根据记录的状态,我想隐藏e div中的所有按钮,但由于某种原因,以下内容无效:

$('#violationFooter').find('input,button').prop('disabled', true);

I've tried several other settings, the following hide the parent div 我已经尝试了其他几个设置,以下隐藏父div

   $('#violationResults').hide();

but this doesn't do anything either 但这也没有做任何事情

   $('#violationResults #violationFooter').hide();

I'm at a loss 我不知所措

EDIT 编辑

   <script id="violationtmpl" type="text/x-jquery-tmpl">
            <div class="row user-infos ${MessageId}">
                <div class="col-xs-12 col-sm-12 col-md-10 col-lg-12">
                    <div class="panel panel-danger">
                        <div class="panel-heading">
                            <h3 class="panel-title">Violation</h3>
                        </div>
                        <div  class="panel-body">
                            <div class="row-fluid">
                                <div class="col-md-9 col-lg-9 hidden-xs hidden-sm">
                                    <table class="table table-user-information" id="scrollable" style="height: 200px;">
                                        <tbody>

                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div id="violationFooter" class="panel-footer">
                            <button class="btn  btn-success btn-xs" type="button" data-toggle="tooltip" data-original-title="Good guy?" onclick="" ><i class="fa fa-user-md"></i></button>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </script> 

*EDIT * *编辑*

This is the call to populate the Template 这是填充模板的调用

function GetViolations(messageId) {

            $.ajax({
                type: "POST",
                url: "Default.aspx/GetViolationMessages",
                cache: false,
                data: JSON.stringify({ messageId: messageId }),
                contentType: "application/json; charset-utf-8",
                dataType: "json",
                error:
                    function(xhr) {

                        var contentType = xhr.getResponseHeader("Content-Type");
                        if (xhr.status === 401 && contentType.toLowerCase().indexOf("text/html") >= 0) {
                            window.location.reload();
                        }
                    },
                success: function(msg) {
                    // Need to work out a way of refreshing the screen

                    $.each(msg.d, function(index, item) {

                        $('#violationtmpl').tmpl(item).appendTo('#violationResults');

                    });


                    var panels = $('.user-infos');
                    var panelsButton = $('.dropdown-user');
                    panels.hide();

                    //Click dropdown
                    panelsButton.click(function() {
                        //get data-for attribute
                        var dataFor = $(this).attr('data-for');
                        var idFor = $(dataFor);

                        //current button
                        var currentButton = $(this);
                        idFor.slideToggle(400, function() {
                            //Completed slidetoggle
                            if (idFor.is(':visible')) {
                                currentButton.html('<i class="glyphicon glyphicon-chevron-up text-muted"></i>');
                            } else {
                                currentButton.html('<i class="glyphicon glyphicon-chevron-down text-muted"></i>');
                            }
                        });
                    });

                    $('[data-toggle="tooltip"]').tooltip();
                }
            });
        };

EDIT 编辑

rendered HTML image 呈现HTML图像

在此输入图像描述

try this: 尝试这个:

$('#violationFooter button').hide()

or better 或更好

$('.panel-footer button').hide()

html HTML

<button class="btn  btn-success btn-xs hideButton" type="button" data-toggle="tooltip" data-original-title="Good guy?" onclick="" >
  <i class="fa fa-user-md"></i>
</button>
<button class="btn  btn-success btn-xs" type="button" data-toggle="tooltip" data-original-title="Good guy?" onclick="" >
  <i class="fa fa-user-md"></i>
</button>

jquery jQuery的

$('.hideButton').css("display", "none");
$('.hideButton').hide();

u can add your own class to the buttons that need to hide.. for eg here first button wll hide second will not! 你可以将自己的类添加到需要隐藏的按钮..例如,这里的第一个按钮将隐藏第二个不会!

Ok, so it would appear I was trying to hide something that wasn't there :-) I trace where the buttons were being rendered and i was trying to hide them before they were drawn, dooooh 好的,所以看起来我试图隐藏那些不存在的东西:-)我追踪按钮被渲染的地方,我试图在它们被绘制之前隐藏它们,dooooh

thanks for your input guys 谢谢你输入的人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM