Javascript jQuery在smarty代码上抛出未捕获错误
我有以下错误消息Javascript jQuery在smarty代码上抛出未捕获错误,javascript,jquery,smarty,prestashop,prestashop-1.5,Javascript,Jquery,Smarty,Prestashop,Prestashop 1.5,我有以下错误消息 Uncaught Error: Syntax error, unrecognized expression: [value={if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{/if}] 源于此代码的: $('.id_state option[value={if isset($smarty.post.id_state) {$smarty.post.id_state|intval}{/if}]').pr
Uncaught Error: Syntax error, unrecognized expression: [value={if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{/if}]
源于此代码的:
$('.id_state option[value={if isset($smarty.post.id_state) {$smarty.post.id_state|intval}{/if}]').prop('selected', true);
我不知道它为什么会抛出这样的错误,因为它后面的代码(实际上是下一行)工作起来很有魅力
以下代码正常工作
$('.id_state_invoice option[value={if isset($smarty.post.id_state_invoice)}{$smarty.post.id_state_invoice|intval}{/if}]').prop('selected', true);
isset()之后缺少一个}结束符。您的代码:
{if isset($smarty.post.id_state) {$smarty.post.id_state|intval}{/if}
需要:
{if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{/if}
你错过了
}
之后的($smarty.post.id\u state)
谢谢你注意到这一点,我想我现在需要更多的咖啡因