引导链接在模态不工作:JQuery的错误
问题描述:
我有一些HTML引导链接在模态不工作:JQuery的错误
<div class="modal fade" id="product-add-to-cart-modal-ssbt" tabindex="-1" role="dialog" aria-hidden="true" style="display: none;">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div class="row quick-view product-main">
<div class="col-sm-12">
<p class="lead text-center">One <b>{Product Name}</b> will be added to your cart.
</p>
<div class="box">
<p class="text-muted text-small text-center">
What do you want to do next?
</p>
<div class="box-footer" id="add-to-cart-buttons">
<a href="?add_product=10161">
<i class="fa fa-reply"></i>Return to current page
</a>
<a href="/site/cart?add_product=10161">
<i class="fa fa-shopping-cart"></i>Go to shopping cart
</a>
</div>
</div>
<!-- /.box -->
</div>
</div>
</div>
</div>
</div>
<!--/.modal-dialog-->
</div>
<button class="btn btn-primary" data-toggle="modal" data-target="#product-add-to-cart-modal-ssbt" onclick="return false;">Add to cart</button>
当我点击任何在我的模态的两个环节,它不会去任何地方。望着控制台,我看到这个错误:
Uncaught Error: Syntax error, unrecognized expression: ?add_product=10161
然后引用jQuery的1.11.1.min.js:2右侧。
我无法在JSFiddle中复制我的错误。它在那里工作。看到这里:http://jsfiddle.net/gk6o4cmr/
有人可以帮我找出我的代码有什么问题吗?
答
我发现了这个问题。 此按钮和模式位于选项卡内。出于某种原因,我在本页面的底部有一段脚本正在改变tab div内的achor标签的行为。
jQuery('#product_details_tabs a').not('.external-link').click(function (e) {
e.preventDefault()
jQuery(this).tab('show')
})
事实证明,我更新了一些代码后,我不需要这个脚本,所以通过删除它,问题就消失了。
尝试分配完全限定的URL - * http:// ....?add_product = 10161 * – 2015-04-01 08:36:52
未捕获的错误:语法错误,无法识别的表达式:http:// ...?add_product = 10161 – narfie 2015-04-01 08:39:11
试试这个http: //jsfiddle.net/shaun1ak/suun90a2/。我修改了'',并且使用了jQuery。出于某种原因,Modal不适用于查询参数。 – 2015-04-01 08:52:00