我有以下错误信息

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);

最佳答案

您的代码:

{if isset($smarty.post.id_state) {$smarty.post.id_state|intval}{/if}


需要是:

{if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{/if}

关于javascript - jQuery在Smarty代码上引发未捕获的错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29396735/

10-13 02:41