【发布时间】:2018-08-23 21:36:45
【问题描述】:
我正在尝试在我的 bigcommerce 基石主题中创建此工具提示。
我已遵循所有步骤。但图片本身并没有出现在我的网站上。
它显示在我的内容中
<span id="service-time" style="display: none;">[INFO TO BE SHOWN WITH THE TOOLTIP]</span>
我用
`<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>`
`<script type="text/javascript" src="/content/jquery.qtip-1.0.0-rc3.js"></script>`
这是 tooltips.js
<script>
$(document).ready(function() {
$("div[data-product-option-change] .form-field").each(function() {
var optionLabel = $(this).sibling('.form-label small');
var optionLabelText = optionLabel.children("label.form-label.form-label--alternate.form-label--inlineSmall").children(".form-label").text();
// check that optionLabelText is not an empty string
if ($("img", this).length < 1 && slugify(optionLabelText).trim().length) {
$(this).sibling('.form-label small')
.children("label.form-label.form-label--alternate.form-label--inlineSmall")
.children(".form-label")
.append(" <div class='help_div' style='display: inline;'><img src='/content/help.gif' alt='" + optionLabelText + "'/></div>");
}
}
});
$('.help_div').each(function() {
var slug = slugify($("img", this).prop('alt'));
var html = $("#" + slug).html();
var titleq = $("img", this).prop('alt').replace(/[^-a-zA-Z0-9,&\s]+/ig, '');
titleq = "<strong style='font-size: 12px'>" + titleq + "</strong><br/>"
if (!html) html = "Description not available yet."
$(this).qtip({
content: titleq + html,
position: {
corner: {
tooltip: 'topRight',
target: 'bottomLeft'
}
},
style: {
tip: {
corner: 'rightTop',
color: '#6699CC',
size: {
x: 15,
y: 9
}
},
background: '#6699CC',
color: '#FFFFFF',
border: {
color: '#6699CC',
}
}
});
});
function slugify(text) {
text = text.replace(/[^-a-zA-Z0-9,&\s]+/ig, '');
text = text.replace(/-/gi, "_");
text = text.replace(/^\s+|\s+$/g, "");
text = text.replace(/\s/gi, "-");
text = text.toLowerCase();
return text;
}
});
</script>
这是我的 HTML:
<div data-product-option-change="" style="">
<div class="form-field" data-product-attribute="set-select">
<label class="form-label form-label--alternate form-label--inlineSmall" for="attribute_250">
Service Time:
<small>Required</small><span class="toolTip" title=""></span>
</label>
</div>
<div class="form-field" data-product-attribute="input-text">
<label class="form-label form-label--alternate form-label--inlineSmall" for="attribute_252">
Event Name:
<small>Required</small><span class="toolTip" title=""></span>
</label>
</div>
</div>
<span id="service-time" style="display: none;">[INFO TO BE SHOWN WITH THE TOOLTIP]</span>
为什么它不起作用?
【问题讨论】:
-
在您的商店中,选项值的类实际上是“productAttributeValue”吗?看起来这些说明可能是为我们的旧版主题平台编写的,并且类名可能不同。
-
您好,感谢您的回复。我检查了一下,似乎这个类实际上是 productOptions-list-item。我尝试更改班级名称。但它仍然不起作用。有什么想法吗?
-
控制台有错误吗?
-
完全没有错误.. 已经工作了好几天,但无济于事。这是我试图完成的页面的链接:store-cvnscu0qdh.mybigcommerce.com/rostrum
-
@KarenWhite 我已经配置了 HTML 部分。我在这里做错了什么?请帮忙!
标签: jquery tooltip bigcommerce qtip jquery-ui-tooltip