开发者

Use a return value in a jQuery template

After some clarification I restate my question as follows.

In a jquery template I've got sth. messy like this to use a return value of a function

<p class="hidden">${$data.score = getScore(results)}</p>

{{tmpl(homeTeam, {score: score}) "#scoreTemplate"}}

Can this be simpli开发者_C百科fied - like the following, which unfortunately doesn't do the trick?

{{tmpl(homeTeam, {score: getScore(results)}) "#scoreTemplate"}}

Many thanks,

Robson


Try something like this,

{{tmpl(
homeTeam, 
{
     teamRole: 'homeTeam', 
     score: d = getScoreByMatch($data, true)
}
) "#scoreTemplate"}}

OR

{{tmpl(
roadTeam, 
{
    teamRole: 'roadTeam', 
    score: d = ${getScoreByMatch($data, false)}
}
) "#scoreTemplate"}}

I have never worked with jquery templates. But this score: d = getScoreByMatch($data, true) syntax will work in javascript.

What i did is just introduced a variable to get the result from getScoreByMatch() method and then assigning that variable's value to the score property.

I am not sure about it will work or not, but just give a try and see.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜