单击节点时不会弹出Bootstrap模式

时间:2013-11-18 01:44:59

标签: javascript twitter-bootstrap d3.js

  'var node = svg.selectAll(".node")
  .data(graph.nodes)
  .enter().append("a")
  .attr("class", "node")
       .attr("target", "_blank")
  .on("click",function(d){click(d)})
  .attr("data-toggle", "modal")
  .call(force.drag);'

 function click(d) 
 { 
 //node.attr("xlink:href",function(d){return d.url;})
 node.attr("data-toggle", "modal")
 node.attr("xlink:href","#myModal")

 }

'<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-    labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal header</h3>
  </div>
  <div class="modal-body">
    <p>One fine body…</p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
  </div>
</div>'

我尝试在节点属性上添加myModal(mymodal在代码下面)  并附加.on('click')以便在单击节点后发生某些事情

但是通过这种方式,我的页面变得只是“隐藏淡出”,但他们没有显示像这里的内页:

http://getbootstrap.com/2.3.2/javascript.html#modals

他们只是让它褪色而没有任何反应,我该如何解决这个问题呢? :)

1 个答案:

答案 0 :(得分:0)

尝试从模态div中删除类hide
<div id="myModal" class="modal <击> hide fade" tabindex="-1" role="dialog" aria- labelledby="myModalLabel" aria-hidden="true">