There isn't a way to access the PHP/Smarty in your javascript as they are executed in two different worlds.
The page is requested from the server. The server executes the PHP and generates the content with Smarty. The server sends the resulting HTML and javascript source code to the client. The server is now done. If another request is received, it starts over anew without knowledge of the previous request.
The client receives HTML and javascript source and displays. The insertVideos
method eventually gets calls. At this point, it has no interaction with the server and the PHP/Smarty features.
From there, the javascript could make an ajax request back to the server or if I make an assumption that you only want to display the videos if the search finds some (results > 0
), you can make that check in javascript and add/modify the dom elements as needed.