“添加到购物车”在我的Magento移动版本中不起作用。它是Jquery-Mobile的构建。
Javascript控制台说
未捕获的TypeError:无法调用未定义的方法“”submit“”
我找了很长时间的代码,但没有找到错误。我对magento和Jquery- mobile版本有点陌生。请帮帮忙。我将在下面分享我的代码。
app/design/frontend/mobile/template/catalog/product/view.phtml
helper('catalog/output'); ?>
getProduct(); ?>
var optionsPrice = new Product.OptionsPrice(getJsonConfig() ?>);
getMessagesBlock()->getGroupedHtml() ?>
getOptions()): ?> enctype="multipart/form-data">
productAttribute($_product, $_product->getName(), 'name') ?>
canEmailToFriend()): ?>
__('Email to a Friend') ?>
getReviewsSummaryHtml($_product, false, true)?>
getChildHtml('alert_urls') ?>
*/ ?>
getChildHtml('product_type_data') ?>
getTierPriceHtml() ?>
getChildHtml('extrahint') ?>
hasOptions()):?>
isSaleable()): ?>
getChildHtml('addtocart') ?>
helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
__('OR') ?>
getChildHtml('addto') ?>
getChildHtml('extra_buttons') ?>
getShortDescription()):?>
__('Quick Overview') ?>
productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?>
getChildHtml('other');?>
isSaleable() && $this->hasOptions()):?>
getChildChildHtml('container1', '', true, true) ?>
getChildHtml('media') ?>
isSaleable() && $this->hasOptions()):?>
getChildChildHtml('container2', '', true, true) ?>
//<![CDATA[
var productAddToCartForm = new VarienForm('product_addtocart_form');
productAddToCartForm.submit = function(button, url) {
alert("hiii");
if (this.validator.validate()) {
var form = this.form;
var oldUrl = form.action;
if (url) {
form.action = url;
}
var e = null;
try {
this.form.submit();
} catch (e) {
}
this.form.action = oldUrl;
if (e) {
throw e;
}
if (button && button != 'undefined') {
button.disabled = true;
}
}
}.bind(productAddToCartForm);
productAddToCartForm.submitLight = function(button, url){
if(this.validator) {
var nv = Validation.methods;
delete Validation.methods['required-entry'];
delete Validation.methods['validate-one-required'];
delete Validation.methods['validate-one-required-by-name'];
if (this.validator.validate()) {
if (url) {
this.form.action = url;
}
this.form.submit();
}
Object.extend(Validation.methods, nv);
}
}.bind(productAddToCartForm);
//]]>
getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
">
getChildData($alias, 'title')):?>
escapeHtml($title); ?>
getChildHtml('upsell_products') ?>
getChildHtml('product_additional_data') ?>
*/ ?>app/design/frontend/mobile/template/catalog/product/view/addtocart.phtml
getProduct(); ?>
__('Add to Cart'); ?>
isSaleable()): ?>
isGrouped()): ?>
__('Qty:') ?>
getChildHtml('', true, true) ?>如您所见,我在javascript提交函数中给出了一个警告。但它并没有出现。
发布于 2012-12-18 14:30:58
在下面这一行后面尝试console.log(productAddToCartForm):
var productAddToCartForm = new VarienForm('product_addtocart_form');输出是什么?确保页面中实际加载了包含这些VarienForm js类的文件。基本上,检查控制台是否有任何可能丢失的JS库,如果您没有修改任何内容,这可能是原因……
发布于 2013-09-03 17:07:41
我注意到,在Internet Explorer中出现该问题是由于合并了JavaScript文件(这是管理中System -> Configuration -> Developer下的一个设置)。
https://stackoverflow.com/questions/13926697
复制相似问题