The example in this article describes the calling method of js in smarty and is shared with everyone for your reference. The specific method analysis is as follows:
1. Question:
Sometimes, in smarty, when js is included, the entire page will not be displayed, and programmers often find errors in the page. The program page and template page have been checked many times but there are no errors, which makes them very depressed.
2. Solution:
Copy the js code in the template page and put it in the new js file, and then include it in the template page, such as:
I hope this article will be helpful to everyone’s PHP programming design.
Smarty array calls do not need to use the ' symbol. To call smarty variables in js, you can assign values in the original js code (must be in the page js code). Example:
{literal}
{/literal}
The smarty value call is generally: {$arr[135].value}. If the value you get is different, please check your code output. Smarty generally does not make mistakes. !
Written in external JS, var abc=<{$row_array}> cannot be parsed into the correct value by smarty, which will cause JS syntax errors. If you need to use JS variables, you must write the variable part in the template file so that it can be parsed into the correct value