gpt4 book ai didi

javascript - js占位符未定义消息错误

转载 作者:行者123 更新时间:2023-12-03 06:44:17 28 4
gpt4 key购买 nike

这个js出了什么问题?它给了我“ Uncaught ReferenceError :msg_newsl未定义”,但它是prestashop的预设模块,所以应该定义它。

js

$(document).ready(function() {

$('#newsletter-input').on({
focus: function() {
if ($(this).val() == placeholder_blocknewsletter ||
$(this).val() == msg_newsl)
$(this).val('');
},
blur: function() {
if ($(this).val() == '')
$(this).val(placeholder_blocknewsletter);
}
});

var cssClass = 'alert alert-danger';
if (typeof nw_error != 'undefined' && !nw_error)
cssClass = 'alert alert-success';

if (typeof msg_newsl != 'undefined' && msg_newsl)
{
$('#columns').prepend('<div class="clearfix"></div><p class="' +
cssClass + '"> ' + alert_blocknewsletter + '</p>');
$('html, body').animate({scrollTop: $('#columns').offset().top},
'slow');
}
});

tpl

<div id="newsletter_block_left" class="block" style="background-color:#efefef; text-align:center">
{*<h4 class="title_block">{l s='Newsletter' mod='blocknewsletter'}</h4>*}
<div class="block_content">
<p style="font-size: 16px;text-transform: uppercase;padding-top: 10px;font-family: 'Questrial', sans-serif;">{l s='stay tuned, subscribe to our newsletter'}</p>
<form action="{$link->getPageLink('index', null, null, null, false, null, true)|escape:'html':'UTF-8'}" method="post">
<div class="form-group{if isset($msg) && $msg } {if $nw_error}form-error{else}form-ok{/if}{/if}" >
<input class=" inputNew form-control grey newsletter-input" id="newsletter-input" type="text" name="email" size="18" value="{if isset($value) && $value}{$value}{else}{l s='your e-mail' mod='blocknewsletter'}{/if}" />
<button type="submit" name="submitNewsletter" class="nsp button button-small">
<p>Subscribe</p>
</button>
<input type="hidden" name="action" value="0" />
</div>
</form>
</div>

最佳答案

检查您是否有:

{strip}
{if isset($msg) && $msg}
{addJsDef msg_newsl=$msg|@addcslashes:'\''}
{/if}
{if isset($nw_error)}
{addJsDef nw_error=$nw_error}
{/if}
{addJsDefL name=placeholder_blocknewsletter}{l s='Enter your e-mail' mod='blocknewsletter' js=1}{/addJsDefL}
{if isset($msg) && $msg}
{addJsDefL name=alert_blocknewsletter}{l s='Newsletter : %1$s' sprintf=$msg js=1 mod="blocknewsletter"}{/addJsDefL}
{/if}
{/strip}

在/themes/your-theme/modules/blocknewsletter/blocknewsletter.tpl

关于javascript - js占位符未定义消息错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37816340/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com