我想从minicart中删除项目,但使用自定义jquery ui popup。这是默认代码 模板/结帐/购物车/ minicart / default.phtml
<?php if (!$this->isOnCheckoutPage()): ?>
<a href="<?php echo $this->getAjaxDeleteUrl() ?>" title="<?php echo $this->__('Remove This Item') ?>"
data-confirm="<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>"
class="remove">
<?php echo $this->__('Remove Item') ?>
</a>
<?php else: ?>
<span><?php echo $this->__('Remove Item') ?></span>
<?php endif; ?>
<?php endif ?>
这很好。但我想要自定义弹出窗口而不是默认警报。所以我使用了jquery popup。
<div id="dialog123" title="Confirmation Required">
Are you sure you would like to remove this item from the shopping cart?
</div>
<a href="<?php echo $this->getAjaxDeleteUrl() ?>" title="<?php echo $this->__('Remove This Item') ?>" class="remove-this-item">
<?php echo $this->__('Remove Item') ?>
</a>
<script type="text/javascript">
var $x=jQuery.noConflict();
$x(document).ready(function() {
$x("#dialog123").dialog({
autoOpen: false,
modal: true
});
});
$x(".remove-this-item").click(function(e) {
e.preventDefault();
var targetUrl = $x(this).attr("href");
$x("#dialog123").dialog({
buttons : {
"Confirm" : function() {
window.location.href = targetUrl;
},
"Cancel" : function() {
$x(this).dialog("close");
}
}
});
$x("#dialog123").dialog("open");
});
</script>
仅使用此弹出窗口,我必须执行ajax删除操作。当确认为是时,上面的代码重定向到下一页。