如何在点击时在javascipt中添加引导模式。到目前为止,我只能在点击时提醒("你好")。我如何提示出一个模态框?
graph.on("click", function (params) {
var node = params['nodes'][0];
displayInfo=false;
if(node!=null){
console.log('node:'+ params['nodes'][0]);
x = params["pointer"]['canvas']['x'];
y = params["pointer"]['canvas']['y'];
displayInfo=true;
lastNode = nodes.get(node);
lastClick = params['pointer'];
//console.log(node);
}
alert("hello");
//add boostrap modal here
});
答案 0 :(得分:0)
你不需要onclick。
<div class="span4 proj-div" data-toggle="modal" data-target="#GSCCModal">Clickable content, graphics, whatever</div>
<div id="GSCCModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">× </button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</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>
</div>
</div>
如果您无论如何都需要onclick事件,请使用如下所示:
graph.on("click", function (params) {
$('#myModal').modal('show');
}
答案 1 :(得分:0)
创建模态HTML并为其指定ID,例如“my_modal” http://getbootstrap.com/javascript/#live-demo
使用代码显示js的模态:
$( “#my_modal”)模态( '显示');
答案 2 :(得分:0)
您可以使用ID
$("#modal-id").modal("show");
或者您可以使用班级名称$(".modal-class").modal("show");
答案 3 :(得分:0)
首先让模态弹出div然后,配置并使用.modal(&#39; show&#39;) 例如: -
<a href="" data-target="#modalDiv" data-toggle="modal"> You can also use onClick call for jquery here. </a>
<div id="modalDiv">
//some content
</div>
在jquery使用中,
$("#modalDiv").modal('show');