简体   繁体   中英

Store javascript codes in velocity vm template file and included in the page

I have javascript code that uses velocity context and rundata objects, I have to have it to be included in a VM template. Is there a way for me to separate it into standalone file, say, screen-js.vm, and included in the GlobalMacros.vm file, like:

and screen-js.vm looks like:

    $data.setLayoutTemplate("/NoNavigationJs.vm") ##this for not creating any header

    <script type="text/javascript">
    $(document).ready(function() {
         //javascript code ...

    }
</script>

But this doesn't work, here is the page source, with 2 empty lines in the begining:

<script type="text/javascript">

$(document).ready(function() {
...
}
</script>

What I did wrong here? Thanks!

David

我知道了:#parse(“ path / to / vm file”)可以。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM