I have a list of items on the webpage and to the right I have Edit buttons.
echo '<a href="#myModal?id='.$row['id'].'" data-toggle="modal" >';
How do I properly pass parameter trough <a>
tag to the bootstrap modal? My code above doesn't work with ?id='.row['id']'
part. I'm getting the Error: Syntax error, unrecognized expression: #myModal?id=12. But <a href="#myModal data-toggle="modal">Edit</a>
opens bootstrap modal.
Thank you
答案 0 :(得分:0)
你没有通过这个传递价值..
href="#myModal?id='.$row['id'].'"
因为这是模态名称..
答案 1 :(得分:0)
您只能通过ajax请求执行此操作。您必须使用ajax函数填充模态。
点击标记的点击事件
例如:
<a href="JavaScript:void(0);" class="aTagclass" data-id="1">open modal</a>
$('.aTagclass').click(function(){
// you can take data-id by
Var id= $(this).data('id');
// call your ajax function using the id
//populate modal
// open modal here
});
注意:上面的代码可能有错误。