$('')。on('shown.bs.modal')事件不会触发任何功能

时间:2018-11-14 10:06:25

标签: javascript bootstrap-modal

我的VisualForce页面具有以下代码:和用于显示图表的javascript标签如下:

<script>
$(document).ready(function() {
$('#idPanelGraphs').on('shown.bs.modal', function () {
    createChart('#barChart2', options);
});
});
</script>   

<div role="tabpanel" class="tab-pane fade idPanel panel-group" id="vertical-tab">
<div id="idPanelGraphs" class="idPanel panel-group collapsible-group" data-chevron-down="glyphicon-chevron-down" data-chevron-up="glyphicon-chevron-up">
   <div class="panel panel-default">
      <div class="panel-body">
         <div class="row">
            <div class="col-md-12">
               <div class="row">
                  <div class="col-md-12">
                     <div id="barChart2" style="height:255px;" />
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </div>
</div>

现在,按照代码,一旦idpanelGraphs处于活动状态,图表应该已经加载。但这不会触发createChart函数。

将模式更改为可折叠时,其作用相同:

 $('#idPanelGraphs').on('shown.bs.collapse', function () {
            createChart('#barChart2', options);
        });


<div role="tabpanel" class="tab-pane fade idPanel panel-group" id="vertical-tab4">
<div id="idPanelGraphs" class="idPanel panel-group collapsible-group" data-chevron-down="glyphicon-chevron-down" data-chevron-up="glyphicon-chevron-up">
   <div class="panel panel-default">
      <div class="panel-heading" data-toggle="collapse" data-target="#collapseGraphTab">
         <h4 class="panel-title">
            Graphs
            <i class="indicator glyphicon glyphicon-chevron-up"/>
         </h4>
      </div>
      <div id="collapseGraphTab" class="panel-collapse collapse">
         <div class="panel-body">
            <div class="row">
               <div class="col-md-12">
                  <div class="row">
                     <div class="col-md-12">
                        <div id="barChart2" style="height:255px;" />
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </div>
</div>

1 个答案:

答案 0 :(得分:0)

希望这行得通..

ImageView img = (ImageView) findViewById(R.id.{ImageView id});
img.setImageResource(getResources().getIdentifier("ImageName","drawable",getPackageName()));
<div class="panel panel-default fade">
    <div class="panel-heading"><h3 class="panel-title">Panel title</h3></div>
    <div class="panel-body">Panel content</div>
</div>

<button id="test">Show panel</button>