这个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>
答案 0 :(得分:1)
检查您是否:
{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}
atthethemes/your-theme/modules/blocknewsletter/blocknewsletter.tpl
答案 1 :(得分:0)
我发现问题,在tpl上写了l s='your e-mail'
而不是l s='Enter your e-mail'