开发者

Play framework include javascript problems

I want to include a javascript file to clean my template code. And I found this template function:

#{script 'search.js'开发者_运维百科 /}

And included the following code:

$(function() {
    $("input:submit").button();
});

Everything is going well. It was included by play and everything is fine. So I started to do some more of my javascript in the file:

$(function() {

    $("input:submit").button();

});

$(function() {

    var availableTags = #{jsAction @Request.autocomplete() /} 

    $("#search").autocomplete({

        source: availableTags(),

        delay: 0,

        minLength: 3

    });

});

But now it is not loaded?!! Anyone an idea what the error is? The code was in the html javascript section before, so I should work...


Play doesn't parse template tags inside Javascript files


This line

#{jsAction @Request.autocomplete() /} 

Cannot work in a JavaScript file, as it is not parsed by Play,but instead statically loaded. Therefore you would need this line to be inside your view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜