admin管理员组文章数量:1414893
<div id="deleteModal" class="modal hide fade" tabindex="-1" role="dialog">
<div class="modal-body">
<span><i class=" icon-info-sign"></i>
</div>
<div class="modal-footer">
<a class="trashconfirm btn btn-info" data-dismiss="modal" href="javascript:void(0)">Yes</a>
<a class="btn btn-info" data-dismiss="modal">No</a>
</div>
</div>
I am using jquery to set the hre.
$(".accordion").on('click','.dairytrash',function() {
var id = $(this).closest('tr').attr('id');
var ele = $(".modal-footer .trashconfirm ");
ele.attr('href','<c:url value="/delete?id='+id+'" />');
});
The href is also setting properly but when i click nothing is happening.
<div id="deleteModal" class="modal hide fade" tabindex="-1" role="dialog">
<div class="modal-body">
<span><i class=" icon-info-sign"></i>
</div>
<div class="modal-footer">
<a class="trashconfirm btn btn-info" data-dismiss="modal" href="javascript:void(0)">Yes</a>
<a class="btn btn-info" data-dismiss="modal">No</a>
</div>
</div>
I am using jquery to set the hre.
$(".accordion").on('click','.dairytrash',function() {
var id = $(this).closest('tr').attr('id');
var ele = $(".modal-footer .trashconfirm ");
ele.attr('href','<c:url value="/delete?id='+id+'" />');
});
The href is also setting properly but when i click nothing is happening.
Share Improve this question edited Mar 18, 2013 at 10:12 Saurabh Kumar asked Mar 18, 2013 at 9:55 Saurabh KumarSaurabh Kumar 16.7k49 gold badges142 silver badges219 bronze badges 4-
2
<c:url...
isn't a valid URL. It looks as if you're trying to use server side constructs on the client side. – robertklep Commented Mar 18, 2013 at 9:58 - No i am finally seeing the correct url to set using firebug like /Spring-Security/delete?id='123456' – Saurabh Kumar Commented Mar 18, 2013 at 10:03
- You are trying to use a JSP url in Javascript, i dont think that url gets parsed by JSP and translated into a valid URL for the client side. Im not sure this is the problem though. – cernunnos Commented Mar 18, 2013 at 10:04
- <a class="trashconfirm btn btn-info" href="/Spring-Security/deletediary?id=1363599032377" data-dismiss="modal">Yes</a> .That what firebug is showing me – Saurabh Kumar Commented Mar 18, 2013 at 10:04
2 Answers
Reset to default 4If you use data-dismiss="modal"
on a button (which you do), Bootstrap will attach a click-handler on it to hide the modal if the button is clicked. That handler calls preventDefault()
on the event, so any default actions (like following a href
) won't be triggered anymore.
If you want to both call a URL when the button is clicked and hide the modal, you're going to have to use Javascript to attach an event handler to your button which will both call the URL and hide the modal.
Use one of the event hooks described in the Bootstrap Docs (http://twitter.github.io/bootstrap/javascript.html), like so :
$('#myModal').on('hidden', function () {
// do something…
})
本文标签: javascriptTwitter bootstrap href in modal not workingStack Overflow
版权声明:本文标题:javascript - Twitter bootstrap href in modal not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745165602a2645657.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论