2015-04-01 33 views
0

我有以下錯誤消息jQuery的罰球上的Smarty代碼未捕獲的錯誤

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

不知道爲什麼它下面會拋出這樣的錯誤,因爲代碼它(literallly下一行)就像一個魅力

下面的代碼正常工作

$('.id_state_invoice option[value={if isset($smarty.post.id_state_invoice)}{$smarty.post.id_state_invoice|intval}{/if}]').prop('selected', true); 
+1

你錯過了'}''後($ smarty.post.id_state)' – 2015-04-01 17:10:25

回答

1

代碼:

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

需求是:

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

感謝注意到,我想我現在需要更多的咖啡因 – Jeremy 2015-04-01 17:45:13

1

您在isset()後遺漏了一個關閉}。